mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
We go to look at the conforming protocols of an associated type but we haven't built the generic environment for the associated type's protocol yet. In the test case given, we find the conformance later via a different path, so everything continues to work. SubstitutionMap::lookupConformance() is hopefully getting a makeover soon, and this hack will go away. Fixes <rdar://problem/31302713>.
25 lines
519 B
Swift
25 lines
519 B
Swift
public protocol Animal {
|
|
associatedtype AnimalSnackType : AnimalSnack
|
|
func snack(on: AnimalSnackType)
|
|
}
|
|
|
|
public protocol AnimalSnack {
|
|
associatedtype EatWith
|
|
func eat(with: EatWith)
|
|
}
|
|
|
|
extension AnimalSnack where EatWith : Animal {}
|
|
|
|
public protocol FurryAnimal : Animal {
|
|
associatedtype Fangs : Animal
|
|
func bite(with: Fangs)
|
|
}
|
|
|
|
extension FurryAnimal {
|
|
public func snack(on: FurryAnimalSnack<Self>) {}
|
|
}
|
|
|
|
public struct FurryAnimalSnack<T : FurryAnimal> : AnimalSnack {
|
|
public func eat(with: T) {}
|
|
}
|