mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
There is an edge case where the Requirement Machine produces a different
minimal signature than the GenericSignatureBuilder:
protocol P {
associatedtype X where X == Self
}
class C : P {
typealias X = C
}
<T where T : P, T : C>
The GenericSignatureBuilder produces <T where T == C> and the Requirement
Machine produces <T where T : C>. The new interpretation makes more sense
with the 'concrete contraction' pre-processing pass that is done now.
The GenericSignatureBuilder's interpretation is slightly more correct,
however the entire conformance is actually invalid if the class is not
final, and we warn about it now.
I'm going to see if we can get away with this minor ABI change without
breaking anything.
24 lines
865 B
Swift
24 lines
865 B
Swift
// RUN: %target-swift-frontend -emit-ir -verify -requirement-machine-abstract-signatures=on %s
|
|
// RUN: %target-swift-frontend -emit-ir -verify -requirement-machine-abstract-signatures=on -disable-requirement-machine-concrete-contraction %s
|
|
|
|
protocol P1 {
|
|
associatedtype A2 : P2 where A2.A1 == Self
|
|
}
|
|
|
|
protocol P2 {
|
|
associatedtype A1 : P1 where A1.A2 == Self
|
|
var property: Int { get }
|
|
}
|
|
|
|
extension P2 {
|
|
var property: Int { return 0 }
|
|
}
|
|
|
|
class C1 : P1 {
|
|
// expected-warning@-1 {{non-final class 'C1' cannot safely conform to protocol 'P1', which requires that 'Self' is exactly equal to 'Self.A2.A1'; this is an error in Swift 6}}
|
|
class A2 : P2 {
|
|
// expected-warning@-1 {{non-final class 'C1.A2' cannot safely conform to protocol 'P2', which requires that 'Self' is exactly equal to 'Self.A1.A2'; this is an error in Swift 6}}
|
|
typealias A1 = C1
|
|
}
|
|
}
|