mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Those tests rely on lexical object lifetimes. But lifetimes are only guaranteed for "variables" but not for temporary objects. Storing those objects in variables fixes the issue. This fixes the tests when running them in optimize mode and when OSSA modules are enabled. This is part of rdar://140229560.
33 lines
569 B
Swift
33 lines
569 B
Swift
// RUN: %target-run-simple-swift | %FileCheck %s
|
|
// REQUIRES: executable_test
|
|
|
|
// https://github.com/apple/swift/issues/51493
|
|
|
|
// CHECK: A
|
|
// CHECK: B
|
|
// CHECK: C
|
|
|
|
protocol SomeProtocol { }
|
|
class SomeClass: SomeProtocol { deinit { print("C") } }
|
|
struct SomeStruct { var x, y: Int }
|
|
|
|
extension SomeProtocol {
|
|
var someProperty: SomeStruct {
|
|
nonmutating set {
|
|
print("B")
|
|
}
|
|
get {
|
|
print("A")
|
|
return SomeStruct(x: 1, y: 2)
|
|
}
|
|
}
|
|
}
|
|
|
|
func testit() {
|
|
let c = SomeClass()
|
|
c.someProperty.x = 32
|
|
}
|
|
|
|
testit()
|
|
|