mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
The Android CI machines cannot execute the test in the target devices. Marking the test as executable makes the test filtering know that this test needs to be executed in the target device.
46 lines
635 B
Swift
46 lines
635 B
Swift
// RUN: %empty-directory(%t)
|
|
// RUN: %target-build-swift -O %s -o %t/a.out
|
|
// RUN: %target-run %t/a.out | %FileCheck %s
|
|
|
|
// REQUIRES: executable_test
|
|
|
|
protocol E {
|
|
func f() -> Bool
|
|
}
|
|
|
|
final class K {
|
|
deinit {
|
|
print("deinit")
|
|
}
|
|
}
|
|
|
|
|
|
struct X : E {
|
|
var x: K
|
|
func f() -> Bool { return true }
|
|
}
|
|
|
|
func g<T>(_ x : T) -> Bool {
|
|
if let y = x as? E { return y.f() }
|
|
return false
|
|
}
|
|
|
|
// CHECK that there is no use-after-free in this function.
|
|
@inline(never)
|
|
func foo(_ x: X) -> Bool {
|
|
return g(x)
|
|
}
|
|
|
|
@inline(never)
|
|
func testit() {
|
|
let x = X(x: K())
|
|
_ = foo(x)
|
|
print(x)
|
|
}
|
|
|
|
// CHECK: X(x: a.K)
|
|
// CHECK: deinit
|
|
testit()
|
|
|
|
|