Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-7245] Cannot automatically synthesize 'Encodable' because 'Encodable' does not conform to 'Encodable' #49793

Open
ankitspd opened this issue Mar 21, 2018 · 5 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. Codable Area → standard library: `Codable` and co. compiler The Swift compiler in itself diagnostics QoI Bug: Diagnostics Quality of Implementation

Comments

@ankitspd
Copy link
Member

Previous ID SR-7245
Radar rdar://problem/38712681
Original Reporter @aciidb0mb3r
Type Bug
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, Codable, DiagnosticsQoI
Assignee None
Priority Medium

md5: c2fb17dbb8301cfd42a4996e555e3351

Issue Description:

The following snippet produces this "weird" error.

struct Foo: Encodable {
    let encodable: Encodable
}
@belkadan
Copy link
Contributor

May be worth special-casing this one. @itaiferber, do you think it's simple enough for a Starter Bug?

@itaiferber
Copy link
Contributor

@belkadan This behaves correctly. You mean for improving the diagnostic?

@belkadan
Copy link
Contributor

Ah, yes, sorry. Just so it doesn't repeat "Encodable" three times!

@itaiferber
Copy link
Contributor

Yeah, seems like this could be a great win for usability. I thought I was going crazy for a moment because I remembered doing this, but PR-10470 improved this for the conditionally conforming collection types at runtime, not for compile-time failures.

I think there's potential for maybe making this a fix-it too. Instead of "because 'Encodable' does not conform to 'Encodable'", we can say "because 'Encodable' does not conform to itself. You must use a concrete type to encode or decode; did you mean to make this type generic?" [need to simplify] and potentially offer to make the type generic on T : Encodable if it isn't already.

@itaiferber
Copy link
Contributor

@swift-ci Create

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. Codable Area → standard library: `Codable` and co. compiler The Swift compiler in itself diagnostics QoI Bug: Diagnostics Quality of Implementation
Projects
None yet
Development

No branches or pull requests

3 participants