Skip to content

Cannot use protocol with primary associated type requirement in protocol composition #75602

@ahoppen

Description

@ahoppen

The following doesn’t compile. I would expect it to. Otherwise I don’t see any way of specifying any kind of String collection that’s sendable.

let x: any Collection<String> & Sendable = [] // error: Non-protocol, non-class type 'Collection<String>' cannot be used within a protocol-constrained type

rdar://132374933

Metadata

Metadata

Assignees

Labels

bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfexistentialsFeature: values of types like `any Collection`, `Any` and `AnyObject`; type-erased valuesparameterized protocolsFeature → protocol: protocols with primary associated typesprotocol compositionsFeature → types: protocol composition typesswift 6.0type checkerArea → compiler: Semantic analysistypesFeature: typesunexpected errorBug: Unexpected error

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions