Skip to content

Can't inherit from a protocol with primary associated types using the "generic" notation #62906

Closed
@tgrapperon

Description

@tgrapperon

It doesn't seem possible for a struct to inherit a protocol with primary associated type using this primary associated type in the declaration. In other words, the following doesn't compile:

protocol P<A> {
  associatedtype A
}
struct B {}

struct T: P<B> {} // Error: Cannot inherit from protocol type with generic argument 'P<B>'

This configuration was however explicitly mentioned in SE-0346, so I don't know if this is a bug, a regression, or feature that was not implemented at the end.

Environment

  • Swift compiler version info: swift-driver version: 1.62.15 Apple Swift version 5.7.2 (swiftlang-5.7.2.135.5 clang-1400.0.29.51)
  • Xcode version info: Version 14.2 (14C18)
  • Deployment target: macOS 13.1

Metadata

Metadata

Assignees

Labels

associated type inferencebugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfconformancesFeature → protocol: protocol conformancesparameterized protocolsFeature → protocol: protocols with primary associated typesswift 5.9type checkerArea → compiler: Semantic analysisunexpected errorBug: Unexpected error

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions