Skip to content

static dynamic member lookup does not work when used in implicit member access expression #84808

@lukaskollmer

Description

@lukaskollmer

Description

while it is possible to use @dynamicMemberLookup with dynamically-looked-up static members, and while it is possible to use the implicit member syntax as a shorthand to omit the type when accessing a static member of a type, it is not possible to combine the two to implicitly access a dynamic member in a context where the expected type is known.

Reproduction

@dynamicMemberLookup
struct S {
    static subscript(dynamicMember _: String) -> Self {
        Self()
    }
}

func f(_: S) {}

f(S.abc) // fine
f(.abc)  // error: type 'S' has no member 'abc'

Expected behavior

the compiler should see that S offers a dynamic member lookup for static members, and should treat f(.abc) the same as f(S.abc)

Environment

swift-driver version: 1.127.14.1 Apple Swift version 6.2 (swiftlang-6.2.0.19.9 clang-1700.3.19.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.triage 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