Skip to content

Code Completion not suggesting argument label if in closure that can match two different result builders #65816

@ahoppen

Description

@ahoppen

The following new test case does not suggest id:. If the overload that takes ToolbarContentBuilder is removed, the test passes

// RUN: %empty-directory(%t)
// RUN: %target-swift-ide-test -batch-code-completion -source-filename %s -filecheck %raw-FileCheck -completion-output-dir %t

struct Group<Content> {
  init(@ToolbarContentBuilder content: () -> Content) {}
  init(@ViewBuilder content2: () -> Content) {}
}

@resultBuilder struct ViewBuilder {
  static func buildExpression(_ content: MyView) -> MyView { content }
  static func buildBlock(_ content: MyView) -> MyView { content }
  static func buildEither(first: MyView) -> MyView { first }
  static func buildEither(second: MyView) -> MyView { second }
}

@resultBuilder struct ToolbarContentBuilder {
  static func buildExpression<Content : ToolbarContent>(_ content: Content) -> Int { 1 }
  static func buildBlock(_ content: Int) -> Int { 1 }
  static func buildEither(first: Int) -> Int { 1 }
  static func buildEither(second: Int) -> Int { 1 }
}

protocol ToolbarContent {}

struct MyView {
  init(_ content: String) {}
  init<Content>(_ data: Int, id: Int, content: (Int) -> Content) {}
}

func test() {
  _ = Group {
    if true {
      MyView("No results")
    } else {
      MyView(1, #^COMPLETE^#) { _ in }
    }
  }
}

// COMPLETE: Pattern/Local/Flair[ArgLabels]:     {#id: Int#}[#Int#]; name=id:

Metadata

Metadata

Assignees

No one assigned

    Labels

    argument labelsFeature: function argument labelsbugA deviation from expected or documented behavior. Also: expected but undesirable behavior.code completionArea → source tooling: code completioncrashBug: A crash, i.e., an abnormal termination of softwaredeclarationsFeature: declarationsfound by stress testerFlag: An issue found by the SourceKit stress testerfuncFeature → declarations: FunctionsoverloadingFeature: Overloading symbol namessource toolingArea: IDE support, SourceKit, and other source toolingswift 5.9

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions