@@ -12,6 +12,7 @@ public class Klass {}
1212
1313func consumingUse( _ k: __owned Klass) { }
1414var booleanValue : Bool { false }
15+ var booleanValue2 : Bool { false }
1516func nonConsumingUse( _ k: Klass ) { }
1617
1718///////////
@@ -94,6 +95,57 @@ public func performMoveOnVarMultiBlockError2(_ p: Klass) {
9495 nonConsumingUse ( x)
9596}
9697
98+ public func performMoveConditionalReinitalization( _ p: Klass ) {
99+ var x = p
100+
101+ if booleanValue {
102+ nonConsumingUse ( x)
103+ let _ = _move ( x)
104+ x = p
105+ nonConsumingUse ( x)
106+ } else {
107+ nonConsumingUse ( x)
108+ }
109+
110+ nonConsumingUse ( x)
111+ }
112+
113+ public func performMoveConditionalReinitalization2( _ p: Klass ) {
114+ var x = p // expected-error {{'x' used after being moved}}
115+
116+ if booleanValue {
117+ nonConsumingUse ( x)
118+ let _ = _move ( x) // expected-note {{move here}}
119+ nonConsumingUse ( x) // expected-note {{use here}}
120+ x = p
121+ nonConsumingUse ( x)
122+ } else {
123+ nonConsumingUse ( x)
124+ }
125+
126+ nonConsumingUse ( x)
127+ }
128+
129+ public func performMoveConditionalReinitalization3( _ p: Klass , _ p2: Klass , _ p3: Klass ) {
130+ var x = p // expected-error {{'x' used after being moved}}
131+ // expected-error @-1 {{'x' used after being moved}}
132+
133+ if booleanValue {
134+ nonConsumingUse ( x)
135+ let _ = _move ( x) // expected-note {{move here}}
136+ nonConsumingUse ( x) // expected-note {{use here}}
137+ nonConsumingUse ( x) // We only emit for the first one.
138+ x = p2
139+ nonConsumingUse ( x)
140+ let _ = _move ( x) // expected-note {{move here}}
141+ nonConsumingUse ( x) // expected-note {{use here}}
142+ } else {
143+ nonConsumingUse ( x)
144+ }
145+
146+ nonConsumingUse ( x)
147+ }
148+
97149// Even though the examples below are for lets, since the let is not initially
98150// defined it comes out like a var.
99151public func performMoveOnLaterDefinedInit( _ p: Klass ) {
0 commit comments