We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
as?
if
switch
1 parent eea590a commit 902409aCopy full SHA for 902409a
test/SILGen/if_expr.swift
@@ -571,3 +571,12 @@ func testCaptureList() -> Int {
571
let fn = { [x = if .random() { 0 } else { 1 }] in x }
572
return fn()
573
}
574
+
575
+// https://github.com/apple/swift/issues/68764
576
+func testConditionalCast<T>(_ x: Any) -> T? {
577
+ if .random() {
578
+ x as? T
579
+ } else {
580
+ nil
581
+ }
582
+}
test/SILGen/switch_expr.swift
@@ -767,3 +767,11 @@ func testCaptureList() -> Int {
767
let fn = { [x = switch Bool.random() { case true: 0 case false: 1 }] in x }
768
769
770
771
772
+func testConditionalCast<T>(_ x: Any, _ y: Int) -> T? {
773
+ switch y {
774
+ default:
775
776
777
0 commit comments