swiftlang / swift

The Swift Programming Language
https://swift.org
Apache License 2.0
67.57k stars 10.35k forks source link

[SR-14738] Code completion not performing global completion in subscript on dynamicMemberLookup type #57088

Open ahoppen opened 3 years ago

ahoppen commented 3 years ago
Previous ID SR-14738
Radar rdar://problem/79092371
Original Reporter @ahoppen
Type Bug
Additional Detail from JIRA | | | |------------------|-----------------| |Votes | 0 | |Component/s | CodeCompletion | |Labels | Bug, FoundByStressTester | |Assignee | None | |Priority | Medium | md5: 5ec040e6c738b2786564fada37f5dbb8

Issue Description:

In the following test case, we are only suggesting dynamicMember: from the subscript inside Binding2 and not index from the global lookup, which is also a valid option and calls through to the subscript on Array

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

var fields: Binding2<[String]> = Binding2()

func morningField() -> Binding2<String> {
  let index = 0
  return fields[#^COMPLETE^#index]
}

@dynamicMemberLookup public struct Binding2<Value> {
  public subscript<Subject>(dynamicMember keyPath: WritableKeyPath<Value, Subject>) -> Binding2<Subject> {
    fatalError()
  }
}
typesanitizer commented 3 years ago

@swift-ci create

ahoppen commented 2 years ago

The issue does not occur if call pattern heuristics are enabled, i.e. if --code-complete-call-pattern-heuristics is passed to swift-ide-test.