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-14890] Code completion is not suggesting tuple labels because type checker is dropping them too early #57237

Closed
ahoppen opened this issue Jul 7, 2021 · 1 comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. code completion Area → source tooling: code completion found by stress tester Flag: An issue found by the SourceKit stress tester source tooling Area: IDE support, SourceKit, and other source tooling

Comments

@ahoppen
Copy link
Contributor

ahoppen commented Jul 7, 2021

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

md5: f480b061a7f95ce2b864f0bceaae4554

Issue Description:

In the following test case 0 and 1 are suggested, not key and value. It appears this is because the type checker is already converting the tuple to an unlabeled tuple (as requested by foo’s return type on the map operation. When the return is removed, key and value are correctly suggested.

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

func foo() -> [(Int, [Int])] {
    var searchResults: [Int: [Int]] = [:]
    searchResults
          .map { $0 }
          .sorted(by: \.#^COMPLETE^#key)
}

public extension Sequence {
    func sorted<T: Comparable>(by keyPath: KeyPath<Element, T>) -> [Element] {
        return sorted { a, b in
            return a[keyPath: keyPath] > b[keyPath: keyPath]
        }
    }
}
@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
ahoppen added a commit to ahoppen/swift-source-compat-suite that referenced this issue Oct 4, 2022
- apple/swift#57237 has been fixed
- A couple of timeouts stopped occurring and a couple new timeouts started ocurring, most likely due to the switch to the new parser
ahoppen added a commit to ahoppen/swift that referenced this issue Oct 4, 2022
ahoppen added a commit that referenced this issue Oct 4, 2022
@ahoppen
Copy link
Contributor Author

ahoppen commented Oct 4, 2022

This issue no longer reproduces in main. Added the test case in #61432.

@ahoppen ahoppen closed this as completed Oct 4, 2022
@AnthonyLatsis AnthonyLatsis added the source tooling Area: IDE support, SourceKit, and other source tooling label Feb 6, 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 found by stress tester Flag: An issue found by the SourceKit stress tester source tooling Area: IDE support, SourceKit, and other source tooling
Projects
None yet
Development

No branches or pull requests

2 participants