Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-14801] Completion in argument label position shows invalid non-argument-label completions (in result builder) #57149

Closed
ahoppen opened this issue Jun 21, 2021 · 1 comment · Fixed by #70012
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. code completion Area → source tooling: code completion source tooling Area: IDE support, SourceKit, and other source tooling

Comments

@ahoppen
Copy link
Contributor

ahoppen commented Jun 21, 2021

Previous ID SR-14801
Radar rdar://79555026
Original Reporter @ahoppen
Type Bug
Additional Detail from JIRA
Votes 0
Component/s CodeCompletion
Labels Bug
Assignee None
Priority Medium

md5: a775b8df2dedca081346ae7d15c9a1d0

Issue Description:

In the following test case when completing foo, bspectRatio gets added a second time after the (.

// RUN: %swift-ide-test -code-completion -source-filename %s -code-completion-token=COMPLETE

protocol View2 {}

extension Never: View2 {}

@resultBuilder struct ViewBuilder2 {
  static func buildBlock() -> Never { fatalError() }
  static func buildBlock<Content>(_ content: Content) -> Content where Content : View2 { fatalError() }
}

struct AsyncImage2<Content> : View2 where Content : View2 {
  init(@ViewBuilder2 content: @escaping (Image2) -> Content) { fatalError() }
}

struct Image2: View2 {}

extension View2 {
  func bspectRatio(foo: Int) -> Never { fatalError() }
}

struct ContentView: View2 {
  var body: some View2 {
    AsyncImage2() { image in
      image.bspectRatio(#^COMPLETE^#foo: 1)
    }
  }
}
@benlangmuir
Copy link
Member

   Decl[InstanceMethod]/OutNominal:    bspectRatio({#foo: Int#})[#Never#]; name=bspectRatio(foo: Int)

This is not a completion of the argument label "foo". It is a completion of the method ContentView.bspectRatio(foo🙂, since the completion is inside ContentView.

There are a couple of problems here:

  1. We are not showing the function call pattern completion "foo: <#Int#>)" at all
  2. We are showing value completions in an argument label position when only argument labels are valid

Note that if there were an overload with an unlabeled first argument bspecRatio(_:...) then (2) would not apply and you should expect to see this method completion, but ideally with a lower priority than the argument label or call pattern completion (1).

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added the source tooling Area: IDE support, SourceKit, and other source tooling label Feb 6, 2023
ahoppen added a commit to ahoppen/swift that referenced this issue Nov 23, 2023
The issue no longer occurs on `main`. Add a test case for it.

Fixes apple#57149
ahoppen added a commit to ahoppen/swift that referenced this issue Nov 23, 2023
The issue no longer occurs on `main`. Add a test case for it.

Fixes apple#57148
Fixes apple#57149
ahoppen added a commit to ahoppen/swift that referenced this issue Nov 24, 2023
The issue no longer occurs on `main`. Add a test case for it.

Fixes apple#57148
Fixes apple#57149
ahoppen added a commit to ahoppen/swift that referenced this issue Nov 24, 2023
The issue no longer occurs on `main`. Add a test case for it.

Fixes apple#57148
Fixes apple#57149
ahoppen added a commit to ahoppen/swift that referenced this issue Nov 24, 2023
The issue no longer occurs on `main`. Add a test case for it.

Fixes apple#57148
Fixes apple#57149
ahoppen added a commit that referenced this issue Nov 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. code completion Area → source tooling: code completion source tooling Area: IDE support, SourceKit, and other source tooling
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants