Files
swift-mirror/test/Generics/rdar123013710.swift
Slava Pestov f747121080 Sema: Re-introduce the hack for re-using generic signature of extended protocol
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.
2024-06-19 13:25:09 -04:00

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}}
}