mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +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.
22 lines
479 B
Swift
22 lines
479 B
Swift
// RUN: %target-typecheck-verify-swift
|
|
|
|
public protocol P {
|
|
associatedtype A
|
|
associatedtype B: P
|
|
|
|
var b: B { get }
|
|
static func f() -> Any?
|
|
}
|
|
|
|
protocol Q: P where B == Never {} // expected-error {{circular reference}}
|
|
|
|
extension Never: Q, P { // expected-note 2{{through reference here}}
|
|
public typealias A = Never
|
|
public static func f() -> Any? { nil }
|
|
}
|
|
|
|
extension Q {
|
|
public var b: Never { fatalError() } // expected-note {{through reference here}}
|
|
}
|
|
|