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.
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.
Attachment: Download
Environment
macOS 11.0.1, Xcode 12.2, Swift 5.3Additional Detail from JIRA
| | | |------------------|-----------------| |Votes | 0 | |Component/s | CodeCompletion | |Labels | Bug | |Assignee | None | |Priority | Medium | md5: 6e592967f51829b15dda241b736860bdIssue 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:
In the above snippet,
barbar
is not offered as a possible completion, onlyfoobar
is. If I move the extension above the point where I am usingfoo
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.