Closed drekka closed 1 year ago
I dropped this into the factory demo and ran it with no issues.
public func factory() -> Container {
Container.shared
}
public typealias DateProviding = () -> Date
public extension Container {
var dateProvider: Factory<DateProviding> { self { { Date() } } }
}
func test() {
// And later in some code...
let date = factory().dateProvider()()
print(date)
}
The problem is probably somewhere in the code you didn't post. You're masking factory or Container with some locally defined name.
Hmm. Ok. Let me dig into that bit more :-)
Ok, my bad. Looks like some subtle missing imports and missing dependency references in a package file. The compiler was still able to find everything through transient dependencies and the likes, but XCode was flagging the errors when it was compiling for code completion. Which explains why it would compile and run fine, then a few seconds later Xcode would flag an error. Anyway, adding the imports and missing dependencies and it all appears to be good now.
Thanks for taking the time to double check :-)
So I have the following code where I'm using Factory to return a closure instead of a type:
This compiles successfully however Xcode then goes an tags it with an error even though there isn't one:
It looks likes Xcode is miss-interpreting this code even though it compiles fine. I've tried
But they all trigger the error. So far it looks like the only thing that removes it is if I do this:
Any thoughts on how to get Xcode to behave?