Open Supereg opened 1 week ago
@Supereg Does it make sense to add this issue to the Swift issue tracker at https://github.com/swiftlang/swift/issues to raise some awareness for this and link to this issue here?
Definitely makes sense. I would just aim to maybe create a small example project. I haven't yet created a minimal example. But will do.
Here seems to be a similar issues with conformances https://github.com/swiftlang/swift/issues/74718
That would be amazing @Supereg!
I think I found the exact issue already reported here https://github.com/swiftlang/swift/issues/74646
Nice; thanks for the find. That is a good small reproducible example 👍
Description
With the latest beta toolchain of Swift 6, the
@Dependency
property wrapper is essentially broken as the dynamic type check is broken with Swift 6.Optional
@Dependency
property declared as follows are broken:´what this calls is this overload of the initializer:
Upon accessing the wrappedValue the
@Dependency
property wrapper implements the following logic:The problem: we reach the preconditionFailure at the bottom.
To summarize: Swift initializes the property wrapper with an initializer that is only available when the property wrapper conforms to
OptionalModuleDependency
, however it is later unable to cast the same property wrapper instance to the said protocolOptionalModuleDependency
.Reproduction
tldr: You can easily reproduce by running the test case
testLoadingAdditionalDependency()
.Minimal Steps:
@Dependency var module0: TestModule?
module0
To verify that Swift is at fault, I augmented the above code snippets with the following print statements:
The output when running the test case:
Expected behavior
Swift should not create paradoxes.
Additional context
No response
Code of Conduct