You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Apple Swift version 5.3.2 (swiftlang-1200.0.45 clang-1200.0.32.28)
Additional Detail from JIRA
Votes
0
Component/s
Compiler
Labels
Bug
Assignee
None
Priority
Medium
md5: b26e9023f315d21187a36a6a6d2ae04f
duplicates:
SR-4248 Runtime exception casting an Any? nil to a generic optional
Issue Description:
The following code produces different results when compiled with swift 5 compiler with -swift-version 4.2, and when compiled with either a swift 4.2 compiler or a swift 5 compiler(not using -swift-version).
Basically when in source code compatibility mode the casting from T to Any?(Optional) fails when T resolves to Optional.
func testfunc()->T{letanynil:Any?=nil
if let castedanynil = anynil as?T{print("casting successful")}else{print("casting failed")}fatalError()}letlala:Any?=testfunc()
Prints "casting failed" when build with swift 5 compiler with input sources version 4.2 e.g .swift -swift-version 4.2 test.swift
Prints "casting successful" in any other case
for example when complied with Apple Swift version 4.2.1 (swift-4.2.1-RELEASE), also prints "casting successful"
The text was updated successfully, but these errors were encountered:
Environment
Apple Swift version 5.3.2 (swiftlang-1200.0.45 clang-1200.0.32.28)
Additional Detail from JIRA
md5: b26e9023f315d21187a36a6a6d2ae04f
duplicates:
Issue Description:
The following code produces different results when compiled with swift 5 compiler with -swift-version 4.2, and when compiled with either a swift 4.2 compiler or a swift 5 compiler(not using -swift-version).
Basically when in source code compatibility mode the casting from T to Any?(Optional) fails when T resolves to Optional.
Prints "casting failed" when build with swift 5 compiler with input sources version 4.2 e.g .swift -swift-version 4.2 test.swift
Prints "casting successful" in any other case
for example when complied with Apple Swift version 4.2.1 (swift-4.2.1-RELEASE), also prints "casting successful"
The text was updated successfully, but these errors were encountered: