mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
We break name lookup circularities by special-casing validation of type aliases, resolving the underlying type of the type alias before building the generic environment of the protocol that contains the type alias. However doing this gives the type alias an underlying type written in terms of unresolved DependentMemberTypes which do not map to associated types. Attempting to substitute such a type fails. We worked around this by re-validating type alias members of protocols when we finally got around to building the protocol's generic environment. Force this to happen earlier in substMemberTypeWithBase(), because we need the fully resolved underlying type in order to perform the substitution. Also, fix TypeAliasDecl::setUnderlyingType() to only create a new NameAliasType the first time it is called. In this special case where it can be called twice with a resolved underlying type the second time, we should not be creating a new NameAliasType. There are better fixes possible here, requiring various levels of refactoring. I'll investigate this soon, but for now this narrow fix should address the problem with minimal risk. Fixes <rdar://problem/33189068>.
20 lines
343 B
Swift
20 lines
343 B
Swift
// RUN: %target-swift-frontend %s -typecheck
|
|
|
|
struct Bar : BarProtocol {
|
|
typealias Element = Int
|
|
}
|
|
|
|
struct Foo: FooProtocol {
|
|
typealias Things = Bar
|
|
func thing() -> Thing {}
|
|
}
|
|
|
|
protocol BarProtocol {
|
|
associatedtype Element
|
|
}
|
|
|
|
protocol FooProtocol {
|
|
associatedtype Things: BarProtocol
|
|
typealias Thing = Things.Element
|
|
}
|