mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
In SIL, the distinction between IUO and Optional is now lowered away, so there's no reason to emit any SIL at all when an IUO is converted to Optional formally in the AST. (Eventually this distinction ought to go away at the type system level too…) Memory promotion didn't understand initializations through unchecked_*_casts and would incorrectly flag them as improper captures, causing rdar://problem/26899492.
33 lines
744 B
Swift
33 lines
744 B
Swift
// RUN: %target-swift-frontend -emit-silgen %s | %FileCheck %s
|
|
|
|
protocol P {}
|
|
|
|
class Foo {
|
|
var x: Foo!
|
|
var p: P!
|
|
|
|
// CHECK-LABEL: {{.*3Foo.*3foo.*}}
|
|
// CHECK-NOT: unchecked_{{.*}}cast {{.*}} Optional{{.*}} to Optional
|
|
func foo() -> Foo? {
|
|
return x
|
|
}
|
|
// CHECK-LABEL: {{.*3Foo.*3poo.*}}
|
|
// CHECK-NOT: unchecked_{{.*}}cast {{.*}} Optional{{.*}} to Optional
|
|
func poo() -> P? {
|
|
return p
|
|
}
|
|
|
|
// CHECK-LABEL: {{.*3Foo.*3bar.*}}
|
|
// CHECK-NOT: unchecked_{{.*}}cast {{.*}} Optional{{.*}} to Optional
|
|
func bar() -> Foo? {
|
|
var x2 = x
|
|
}
|
|
// CHECK-LABEL: {{.*3Foo.*3par.*}}
|
|
// CHECK-NOT: unchecked_{{.*}}cast {{.*}} Optional{{.*}} to Optional
|
|
func par(p3: P) -> P? {
|
|
var p2 = p
|
|
p2! = p3
|
|
p2? = p3
|
|
}
|
|
}
|