Skip to content

Unable to compile extension of generic type with generic subtype using the same type parameters. #64762

@omv-libs

Description

@omv-libs

Description
I found an odd case where the compiler will refuse to compile an extension of a generic type's subtype, with the subtype using the same type parameters as its container type.

Steps to reproduce
Try building the following on current released tooling (Xcode 14.2, Swift 5.7):

struct Property<Value: Equatable> { var value: Value } enum Namespace<Value: Equatable> { typealias Prop = Property<Value> } extension Namespace.Prop { static func buildOne(initialValue: Value) -> Self { return .init(value: initialValue) } }

I get the following error:
<path to file>:<line>:<column> Reference to generic type ‘Namespace’ requires arguments in <...>

Using extension Property instead will compile.

Expected behavior
I'm reasonably sure it should build. Even if I'm wrong about that, the error emitted doesn't make sense.

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 Xcode 14.2 Build version 14C18
  • Deployment target: macOS 13.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    TypeResolverbugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfextensionFeature → declarations: `extension` declarationsgeneric constraintsFeature → generics: generic constraintsgenericsFeature: generic declarations and 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