Casting fails in Swift 6 #74738
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
triage needed
This issue needs more specific labels
Description
When compiling code with the Swift 6 compiler and running in a Swift 5 environment, such as an iOS 17 simulator, casting of values to protocols fails. When running the same code in other environment, such as an iOS 18 simulator, the casting succeeds as I would expect.
I'm not totally sure if there are specific requirements for the protocol or how it's used. The reproduction steps listed below are based off of the part of my codebase that's exhibiting this behavior, and I've confirmed that the issue exists in a fresh project with this code snippet.
Reproduction
Expected behavior
When running with Xcode 16 and targeting an iOS 17 simulator (that is, when using the Swift 6 compiler and targeting a device with a Swift 5 runtime), we should see "The value is wrapped in an optional" printed. Instead, we see "The value is not wrapped in an optional" printed. We see the correct behavior on the iOS 18 simulator. This code also behaves correctly when compiled with the Swift 5 compiler in Xcode 15.
Environment
Xcode 16 Beta 2 (16A5171r)
iOS 17.4 simulator, macOS 14
Apple Swift version 6.0 (swiftlang-6.0.0.4.52 clang-1600.0.21.1.3)
Additional information
I think whatever is causing this behavior, might be causing the behavior in #74333? They're similar enough that I'm suspicious, but I'm also not knowledgable enough with the compiler code to know if that's actually true or if I'm incorrectly relating two issues together.
The text was updated successfully, but these errors were encountered: