[SR-7722] Optional extension protocol not recognized at runtime in release build #50262
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
compiler
The Swift compiler in itself
optimized only
Flag: An issue whose reproduction requires optimized compilation
Environment
Xcode 9.3.1, iOS project
Additional Detail from JIRA
md5: 5a9b2306bfe76c5e6ef2e0c209f7fcbd
Issue Description:
I have a protocol and I do an extension on Optional that ensures that Optional implements this protocol. In some circumstances, Swift fails to recognize that Optional implements this protocol when asked using "as?".
The problem only surfaces in release build, not in debug build.
To reproduce:
Create a new Xcode project, iOS, single view app
Past below code into AppDelegate.swift
Edit the Scheme and change "Run" to use build configuration "Release"
Run
Expect two lines with "10" in console
Actual result: one line with "10" another with "Optional(10)"
At top of AppDelegate.swift:
In
application(application:didFinishLaunchingWithOptions🙂
:I am including pretty2() for reference as going via "Any" seems to be a work-around.
The text was updated successfully, but these errors were encountered: