I'm unsure if this is a bug in Swift/Xcode (I can reproduce in 12.4 and 12.5) or just a weird quirk that I've somehow managed to avoid running into but is it expected that the ability for Xcode to offer auto-complete suggestions is dependent on the order of how things are defined within a source code file? I know that Playgrounds are parsed from top to bottom but I didn't think this was the case for normal source files in a project.
Here's a basic example - in this example no auto-complete suggestions will be offered on the returned AnyPublisher
- you'd expect the normal operators offered on any Combine publisher:
import Combine
import Foundation
let wrapper = Wrapper(createPublisher: { Just("foo").eraseToAnyPublisher() })
// This will not produce any auto-complete suggestions
wrapper.createPublisher().
struct Wrapper {
var createPublisher: () -> AnyPublisher<String, Never>
}
However if Wrapper
is moved above where it is used, auto-complete works as expected:
import Combine
import Foundation
struct Wrapper {
var createPublisher: () -> AnyPublisher<String, Never>
}
let wrapper = Wrapper(createPublisher: { Just("foo").eraseToAnyPublisher() })
// This *will* provide auto-complete suggestions
wrapper.createPublisher().
It feels like if this was normal I'd have run into it before now.