mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
When we see two type(aliase)s with the same name in a protocol hierarchy, make them equal with an implied same-type requirement. This detects inconstencies in typealiases across different protocols, and eliminates the need for ad hoc consistency checking. This is a step toward simplifying away the need for direct-diagnosis operations involving concrete type mismatches. While here, warn when we see an associated type with the same as a typealias from an inherited protocol; in this case, the associated type is basically useless, because it's going to be equivalent to the typealias.
30 lines
777 B
Swift
30 lines
777 B
Swift
// RUN: %target-swift-frontend %s -emit-ir
|
|
|
|
struct MySlice<Base : MyIndexableType> : MyCollectionType {}
|
|
struct MyMutableSlice<Base : MyMutableCollectionType> : MyMutableCollectionType {}
|
|
|
|
protocol MySequenceType {}
|
|
protocol MyIndexableType {}
|
|
|
|
protocol MyCollectionType : MySequenceType, MyIndexableType {
|
|
associatedtype SubSequence = MySlice<Self>
|
|
func makeSubSequence() -> SubSequence
|
|
}
|
|
extension MyCollectionType {
|
|
func makeSubSequence() -> MySlice<Self> {
|
|
typealias S = Self
|
|
return MySlice<S>()
|
|
}
|
|
}
|
|
|
|
protocol MyMutableCollectionType : MyCollectionType {
|
|
associatedtype SubSequence = MyMutableSlice<Self>
|
|
}
|
|
extension MyMutableCollectionType {
|
|
func makeSubSequence() -> MyMutableSlice<Self> {
|
|
typealias S = Self
|
|
return MyMutableSlice<S>()
|
|
}
|
|
}
|
|
|