swiftlang / swift

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

[SR-13893] Code completion ignores code declared below the code needing completion #56290

Open swift-ci opened 3 years ago

swift-ci commented 3 years ago
Previous ID SR-13893
Radar rdar://problem/71709769
Original Reporter mluisbrown (JIRA User)
Type Bug

Attachment: Download

Environment macOS 11.0.1, Xcode 12.2, Swift 5.3
Additional Detail from JIRA | | | |------------------|-----------------| |Votes | 0 | |Component/s | CodeCompletion | |Labels | Bug | |Assignee | None | |Priority | Medium | md5: 6e592967f51829b15dda241b736860bd

Issue Description:

Swift code completion (auto complete in Xcode) does not recognise declarations made below the point at which the completion is being requested.

For example:

struct Foo {
    var bar: String = "bar"

    func foobar() -> String {
        "foo" + bar
    }
}

let foo = Foo()
foo.   // <- completion for barbar() is not available

extension Foo {
    func barbar() -> String {
        bar + bar
    }
}

In the above snippet, barbar is not offered as a possible completion, only foobar is. If I move the extension above the point where I am using foo there is no problem.

This happens in Playgrounds and in regular Swift files in Xcode.

Referenced in this tweet: https://twitter.com/mluisbrown/status/1329903064489336838

and this reply from @benlangmuir : https://twitter.com/benlangmuir/status/1329945253160177665?s=20

I've noticed this more recently as I have been using the Point Free Composable Architecture where it is common to have "Reducers" declared at the top level.

benlangmuir commented 3 years ago

@swift-ci create

ahoppen commented 2 years ago

Duplicate of #51404

ahoppen commented 2 years ago

No longer reproduces on main.