Skip to content

Inconsistent autocompletion results for strongly-typed macro arguments #70094

Closed
@MahdiBM

Description

@MahdiBM

Description

The Swift toolchain should be able to provide full autocompletion results for macros when they're defined in a strongly-typed way in source code.

Reproduction

/// Encodes enums in a custom way.
/// The `fatalError()`s won't even be present anywhere in the code,
/// they are just to make the code compile and not require use to do e.g `default: String? = nil`.
macro CodableEnum(
    default: String = { fatalError() }(),
    conformances: [CodableEnumConformance] = { fatalError() }()
) = #externalMacro(
    module: "CodableEnumMacro",
    type: "CodableEnumMacroType"
)

When trying to annotate a type with this macro, there is no autocompletion results for e.g. CodableEnum(conformances:), but when you type that out, it'll provide autocompletion results for the elements of the array of conformances and when you e.g. write conformances: [.so] it'll show autocompletion for .something.

Expected behavior

Autocomplete like normal Swift code.

Environment

swift-driver version: 1.87.3 Apple Swift version 5.9.2 (swiftlang-5.9.2.2.51 clang-1500.1.0.2.2)
Target: arm64-apple-macosx14.0

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.code completionArea → source tooling: code completionsource toolingArea: IDE support, SourceKit, and other source toolingswift 5.9swift macroFeature → declarations: Swift `macro` declarationsunexpected behaviorBug: Unexpected behavior or incorrect output

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions