mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Works around an oddity of the associated type inference when the potential witness is generic and returns (e.g.) Self. Associated type inference needs to move off of archetypes for the implementation to become sane. For now, this eliminates a crash. Fixes rdar://problem/43591024.
21 lines
360 B
Swift
21 lines
360 B
Swift
// RUN: not %target-swift-frontend -typecheck %s
|
|
|
|
// Was crashing in associated type inference.
|
|
|
|
protocol P {
|
|
associatedtype Assoc
|
|
|
|
subscript(i: Int) -> Assoc { get }
|
|
func f() -> Assoc
|
|
}
|
|
|
|
struct X<T, U> { }
|
|
|
|
extension P {
|
|
subscript<T>(i: T) -> X<T, Self> { return X<T, Self>() }
|
|
func f<T>() -> X<T, Self> { return X<T, Self> }
|
|
}
|
|
|
|
struct Y<T>: P { }
|
|
|