You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SR-6468 inheriting from class with synthesized Codable implementation creates invalid code
relates to:
SR-7090 Crashing with EXC_BAD_ACCESS after decoding Codable subclass
Issue Description:
The compiler is able to synthesize Encodable conformance for certain types, including classes. However, something about the synthesized encode(to: ) method isn't right; it results in vtable lookup corruption when such classes are accessed from another source file:
a.swift:
class Base: Encodable {}
class Derived: Base {
var derived10: Int { return 10 }
var derived20: Int { return 20 }
}
main.swift:
let d = Derived()
print("d.derived20 == \(d.derived20)") // Prints 10 (expected: 20)
print("d.derived10 == \(d.derived10)") // crash (expected: 10)
Attachment: Download
Environment
Reproducible on all active swift branches, has been like this since SE-0166 landed in Swift 4.0 in Xcode 9.0.
Additional Detail from JIRA
md5: 4d3289965aff0abe24dad7917cc5f140
duplicates:
relates to:
Issue Description:
The compiler is able to synthesize Encodable conformance for certain types, including classes. However, something about the synthesized encode(to: ) method isn't right; it results in vtable lookup corruption when such classes are accessed from another source file:
a.swift:
main.swift:
Try:
Apparently main.swift and a.swift disagree about the existence of the encode method in Derived's vtable, which makes the Derived class unusable.
The text was updated successfully, but these errors were encountered: