Skip to content

Concrete implementation of a generic protocol does not inherit the type aliases from the generic protocol #61712

Open
@coinbump

Description

@coinbump

Describe the bug
Concrete implementation of a generic protocol does not inherit the type aliases from the generic protocol

Steps To Reproduce

protocol MyThing<First, Second> {
  associatedtype First
  associatedtype Second

  typealias Convenience = (Result<First, Error>) -> Void

  func doSomething(completion: @escaping Convenience)
}

protocol MyMoreConcreteThing: MyThing<String, Int> {
}

class MyConcreteThing: MyMoreConcreteThing {
    var completion: Convenience?

    func doSomething(completion: @escaping Convenience) { // ERROR HERE: Reference to invalid type alias
    }
}

This won't build due to the error: "Reference to invalid type alias 'Convenience' of type 'MyConcreteThing'". However the concrete implementation of the generic protocol should still have access to the generic protocol's type alias.

Metadata

Metadata

Assignees

Labels

associated type inferencebugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfconformancesFeature → protocol: protocol conformancestype checkerArea → compiler: Semantic analysis

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions