mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
This feature allows the following construct to work:
protocol P1 {
associatedtype T : P1
}
protocol P2 {
associatedtype T : P2
}
func foo<T : P1 & P2>(_: T) {}
However, I haven't figured out how to make it work with rewrite system
minimization, so it's already disabled when you use the requirement
machine for protocol or generic signature minimization. In addition to
that it adds some complexity.
I haven't found any real-world uses of this pattern yet, so I'm going
to try to turn it off, and if nobody complains, remove the support
altogether.
If people do complain, we'll have to figure out how to make it work with
minimization.
26 lines
518 B
Swift
26 lines
518 B
Swift
// RUN: %target-typecheck-verify-swift
|
|
|
|
protocol P1 {
|
|
associatedtype T : P1
|
|
}
|
|
|
|
protocol P2 {
|
|
associatedtype T : P3
|
|
}
|
|
|
|
protocol P3 {
|
|
associatedtype T : P1
|
|
}
|
|
|
|
struct S<T : P1 & P2> {}
|
|
|
|
protocol Base {
|
|
associatedtype T : Base // expected-note {{'T' declared here}}
|
|
}
|
|
|
|
protocol Derived1 : Base {
|
|
associatedtype T : Derived1 // expected-warning {{redeclaration of associated type 'T' from protocol 'Base' is better expressed as a 'where' clause on the protocol}}
|
|
}
|
|
|
|
protocol Derived2 : Base where T : Derived2 {}
|