mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
In Swift 5.10 if you wrote `extension Foo {}` for some protocol Foo,
the extension would always re-use the generic signature of Foo, which
is <Self where Self: Foo>. In Swift 6 this no longer works because Foo
might be ~Copyable, in which case `extension Foo {}` adds default
requirements, so we changed GenericSignatureRequest to just always
build a new signature if we're given an extension.
However, to avoid a request cycle with a code example that really should
have never worked at all, I'm re-introducing the hack for re-using the
signature.
Fixes rdar://problem/129540617.
42 lines
603 B
Swift
42 lines
603 B
Swift
// RUN: %target-typecheck-verify-swift
|
|
|
|
protocol P1 {
|
|
typealias A = P2
|
|
}
|
|
|
|
protocol P2 {
|
|
associatedtype B
|
|
typealias A1 = Int
|
|
func f1()
|
|
}
|
|
|
|
extension P2 {
|
|
typealias A2 = String
|
|
func f2() {}
|
|
}
|
|
|
|
extension P1 where Self: A {
|
|
typealias B1 = A1
|
|
typealias B2 = A2
|
|
|
|
func g() {
|
|
f1()
|
|
f2()
|
|
}
|
|
}
|
|
|
|
// This is terrible and we should ban it some day
|
|
extension P1 where Self: A, B: Hashable {
|
|
func h(_: Set<B>) {}
|
|
}
|
|
|
|
// This is also terrible and we should ban it
|
|
public protocol P3 {
|
|
associatedtype A
|
|
}
|
|
|
|
public protocol P4: P3 where A == B {}
|
|
|
|
extension P4 {
|
|
public typealias B = String
|
|
} |