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-9533] Compiler crash: same name associatedtype in conditional conformance #51984
Comments
Typealiases in constrained extensions aren't actually constrained today, which means this is allowed as a conformance of P2 when it shouldn't be. (The compiler shouldn't crash, of course.) cc @DougGregor, @slavapestov |
You can also get the compiler to crash with the Swift 5 compiler if you add a constraint on the associated type. (Curiously enough, Swift 4.2 doesn't crash here.) (Since it's so similar I just decided to post it here instead of create a new issue.) protocol AssociatedTypeProto {}
class AssociatedTypeProtoClass: AssociatedTypeProto {}
protocol Proto1 {
associatedtype SameNameAssociatedType: AssociatedTypeProto
}
protocol Proto2 {
associatedtype SameNameAssociatedType: AssociatedTypeProto
}
struct Box<T> {}
extension Box: Proto1 where T: Proto1 {
typealias SameNameAssociatedType = T.SameNameAssociatedType
// typealias SameNameAssociatedType = AssociatedTypeProtoClass // OK
}
extension Box: Proto2 where T: Proto2 {} This gets you this output on master with assertions enabled:
|
I remember fixing this a while back: q.swift:15:1: error: type 'Box<T>' does not conform to protocol 'P2'
extension Box: P2 where T: P2 {
^
q.swift:6:20: note: protocol requires nested type 'X'; do you want to add it?
associatedtype X
^ |
Environment
DEVELOPMENT-SNAPSHOT-2018-12-17-a
Additional Detail from JIRA
md5: a92d370a0edc9ed1c579e9affae8f3d7
Issue Description:
This code doesn't crash. But adding below code results segment fault.
The text was updated successfully, but these errors were encountered: