When a protocol implementation uses a type that has the same name as the protocol's associatedtype, changing the protocol's definition from var b: B? to var b: [B] suddenly causes a compiler error.
Reproduction
protocol A {
associatedtype B
// var b: B? { get set }
var b: [B] { get set }
}
class AImpl: A { // error: Type 'AImpl' does not conform to protocol 'A'
// var b: B?
var b = [B]() // error: Unsupported recursion for reference to type alias 'B' of type 'AImpl'
}
struct B {
}
Note that this problem wouldn't happen when renaming struct B to something different, like struct BImpl.
Expected behavior
Either no error, or the same error as when changing var b: [B] to var b: B? (see commented out lines).
Environment
swift-driver version: 1.115 Apple Swift version 6.0.2 (swiftlang-6.0.2.1.2 clang-1600.0.26.4)
Target: arm64-apple-macosx15.0
Description
When a protocol implementation uses a type that has the same name as the protocol's
associatedtype
, changing the protocol's definition fromvar b: B?
tovar b: [B]
suddenly causes a compiler error.Reproduction
Note that this problem wouldn't happen when renaming
struct B
to something different, likestruct BImpl
.Expected behavior
Either no error, or the same error as when changing
var b: [B]
tovar b: B?
(see commented out lines).Environment
swift-driver version: 1.115 Apple Swift version 6.0.2 (swiftlang-6.0.2.1.2 clang-1600.0.26.4) Target: arm64-apple-macosx15.0
Additional information
No response