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-7315] Decodable conformance of classes in different files yields bogus "Class ... has no initializers" error #49863
Comments
cc @itaiferber |
Comment by Dave Poirier (JIRA) Associated apple docs: https://developer.apple.com/documentation/foundation/archives_and_serialization/encoding_and_decoding_custom_types All examples provided by Apple showcase the automatic compiler-generated initializers; there should not be any need to manually create the initializers if all properties are Codable/Decodable. |
@swift-ci create |
Apologies for the delay in responding — I just got back from vacation. I can replicate this with Swift 4.1; class C : Decodable {
let c1: C1? = nil
} Dropping class C {
let c1: C1? = nil
} Giving |
You'd get this same error, of course, if you dropped class C {
let c1: C1
} Synthesis of In any case, I'll try to investigate this too with some of the other tasks that I have. |
Shouldn't both C and C1 get an init(from🙂 synthesized? It looks like a bug in the type checker. I'm looking into it. |
@slavapestov Yes, they should, and I think they do; I haven't had time to look into this, but if I had to guess, the diagnostic is being produced after |
It looks like they're not being synthesized, which also explains the related bugs where vtable layout between translation units is inconsistent and causes runtime crashes. |
I investigated this, same root cause as https://bugs.swift.org/browse/SR-6468. |
Environment
Swift version 4.2-dev (LLVM 95345677bd, Clang daefc772c1, Swift 76c264e)
Target: x86_64-apple-darwin17.4.0
Additional Detail from JIRA
md5: 041c433776ada41d9784d150b3a3cc07
Issue Description:
The following Swift files fail to compile:
But they really should as we should be synthesising an
init(from:)
forC1
. Note that the above example does compile with whole module optimisation enabled if the file a.swift comes before b.swift.The text was updated successfully, but these errors were encountered: