mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
27 lines
770 B
Swift
27 lines
770 B
Swift
// RUN: %target-swift-frontend -emit-sil %s | FileCheck %s
|
|
|
|
// Make sure that materializations of computed properties such as 'false' and
|
|
// 'true' don't leave needless stack allocations. <rdar://problem/15272642>
|
|
|
|
// CHECK-LABEL: sil hidden @_TF28allocbox_to_stack_with_false1gFT_T_ : $@convention(thin) () -> () {
|
|
// CHECK-NOT: alloc_stack
|
|
// CHECK-NOT: dealloc_stack
|
|
// CHECK: }
|
|
func g() {
|
|
if false {}
|
|
}
|
|
|
|
// Verify we don't crash on this.
|
|
// rdar://15595118
|
|
infix operator ~> { precedence 255 }
|
|
protocol Target {}
|
|
|
|
func ~> <Target, Arg0, Result>(x: inout Target, f: (_: inout Target, _: Arg0) -> Result) -> (Arg0) -> Result {
|
|
return { f(&x, $0) }
|
|
}
|
|
|
|
func ~> (x: inout Int, f: (_: inout Int, _: Target) -> Target) -> (Target) -> Target {
|
|
return { f(&x, $0) }
|
|
}
|
|
|