mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
If a nested type of a generic parameter was a typealias, and the generic parameter was not at depth 0, index 0, we would resolve the type down to the wrong PotentialArchetype, causing bogus diagnostics and crashes. Make sure we apply a substitution to the typealias's underlying type before resolving it, to map it to the correct PotentialArchetype. Note that the original test case in the radar works now, but the more comprehensive test I added exposes an existing problem where generic signature canonicalization is not idempotent. When this is fixed, the RUN: line in the test can be changed from -typecheck to -emit-ir. Fixes <rdar://problem/30248571>.
53 lines
881 B
Swift
53 lines
881 B
Swift
// RUN: %target-swift-frontend %s -typecheck
|
|
// FIXME: %target-swift-frontend %s -emit-ir -- see https://github.com/apple/swift/pull/7414
|
|
|
|
protocol P {
|
|
associatedtype A
|
|
associatedtype B
|
|
}
|
|
|
|
protocol Q : P {
|
|
associatedtype M
|
|
typealias A = M
|
|
|
|
}
|
|
|
|
|
|
extension Q {
|
|
typealias B = M
|
|
}
|
|
|
|
protocol R {
|
|
associatedtype S
|
|
|
|
init()
|
|
}
|
|
|
|
extension R {
|
|
init<V : Q>(_: V) where V.M == Self {
|
|
let _ = V.A.self
|
|
let _ = V.B.self
|
|
let _ = V.M.self
|
|
let _ = Self.self
|
|
|
|
let _: V.M.Type = V.A.self
|
|
let _: V.M.Type = V.B.self
|
|
let _: V.M.Type = Self.self
|
|
|
|
let _: V.A.Type = V.M.self
|
|
let _: V.A.Type = V.B.self
|
|
let _: V.A.Type = Self.self
|
|
|
|
let _: V.B.Type = V.M.self
|
|
let _: V.B.Type = V.A.self
|
|
let _: V.B.Type = Self.self
|
|
|
|
let _: Self.Type = V.A.self
|
|
let _: Self.Type = V.B.self
|
|
let _: Self.Type = V.M.self
|
|
|
|
self.init()
|
|
}
|
|
}
|
|
|