Skip to content

Parameter packs + generic static member lookup + expressible by literal = failure #78912

@stephencelis

Description

@stephencelis

Description

In a parameter pack context, generic static member lookup fails to type check an expressible by literal value.

Reproduction

This demonstrates the issue, but replacing I for any other literal, like integers or string interpolation, fails in similar ways.

protocol P<T> {
  associatedtype T
}

struct S<T>: P {}

struct I: ExpressibleByStringLiteral {
  init(stringLiteral value: String) {}
}

extension P {
  static func f<T>(_ i: I, as: T.Type) -> Self where Self == S<T> {
    Self()
  }
}

func f<each T: P>(_: () -> (repeat each T)) {
}

func g() {
  f { (.f("", as: Int.self), .f("", as: Int.self)) }
  // error: Cannot convert value of type 'String' to expected argument type 'I'
}

Expected behavior

I expect .f's first literal string value to go through the associated I's expressible by string literal conformance.

Environment

swift-driver version: 1.115.1 Apple Swift version 6.0.3 (swiftlang-6.0.3.1.10 clang-1600.0.30.1)
Target: arm64-apple-macosx15.0

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.parameter packsFeature → generics: Parameter packstriage neededThis issue needs more specific labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions