Files
swift-mirror/validation-test/compiler_crashers_2_fixed/0042-rdar21775089.swift
Doug Gregor c47aea7150 [GSB] Cope with typealiases within protocol hierarchies.
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.
2017-06-23 17:25:45 -07:00

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>()
}
}