mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
The same base value is necessary to invoke other accessors as part of the same access, but we would end up consuming it as part of materializing the base value for calls into nonmutating setters. Fixes SR-8990 | rdar://problem/45274900.
27 lines
490 B
Swift
27 lines
490 B
Swift
// RUN: %target-run-simple-swift | %FileCheck %s
|
|
// REQUIRES: executable_test
|
|
|
|
// SR-8990
|
|
|
|
// 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)
|
|
}
|
|
}
|
|
}
|
|
|
|
SomeClass().someProperty.x = 32
|