@@ -12,6 +12,7 @@ public class Klass {}
12
12
13
13
func consumingUse( _ k: __owned Klass) { }
14
14
var booleanValue : Bool { false }
15
+ var booleanValue2 : Bool { false }
15
16
func nonConsumingUse( _ k: Klass ) { }
16
17
17
18
///////////
@@ -94,6 +95,57 @@ public func performMoveOnVarMultiBlockError2(_ p: Klass) {
94
95
nonConsumingUse ( x)
95
96
}
96
97
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
+
97
149
// Even though the examples below are for lets, since the let is not initially
98
150
// defined it comes out like a var.
99
151
public func performMoveOnLaterDefinedInit( _ p: Klass ) {
0 commit comments