Skip to content

Request cycle when generic parameter witnesses associated type requirement #82221

Open
@jeremyabannister

Description

@jeremyabannister

Description

While reducing the code to demonstrate this other bug I discovered another behavior that surprised me. I don't know if it is a bug or just unhelpful diagnostic messaging for a genuine problem.

Reproduction

protocol A0 {
    associatedtype C: C0<Self>
}

protocol B0<K>: A0 where C: D0<K> {
    associatedtype K
}

protocol C0<A> {
    associatedtype A: A0
}

protocol D0<K>: C0 {
    associatedtype K
}

struct A1<K>: B0 {
    typealias C = C1<Self, K> // Error: Type alias 'C' references itself
//    typealias K = K // Uncommenting this fixes it
}

struct C1<A: B0<K>, K>: D0 {}

Expected behavior

I expect it to either compile or explain to me more clearly what the problem is

Environment

Swift 6.1
Xcode Version 16.4 (16F6)

Additional information

No response

Metadata

Metadata

Assignees

Labels

associated type inferencebugA deviation from expected or documented behavior. Also: expected but undesirable behavior.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions