Files
swift-mirror/test/Interpreter/lifetime_nonmutating_address_only.swift
Joe Groff dab6891573 SILGen: Borrow the base of accessor LValueComponents.
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.
2018-10-15 20:08:17 -07:00

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