@@ -8,7 +8,9 @@ import Swift
8
8
// Declarations //
9
9
//////////////////
10
10
11
- public class Klass { }
11
+ public class Klass {
12
+ public func getOtherKlass( ) -> Klass ? { return nil }
13
+ }
12
14
13
15
struct KlassWrapper {
14
16
var k : Klass
@@ -19,7 +21,9 @@ var booleanValue: Bool { false }
19
21
func nonConsumingUse< T> ( _ k: T ) { }
20
22
func exchangeUse< T> ( _ k: __owned T) -> T { k }
21
23
22
- public protocol P { }
24
+ public protocol P {
25
+ var k : Klass { get }
26
+ }
23
27
public protocol SubP1 : P { }
24
28
public protocol SubP2 : P { }
25
29
@@ -214,16 +218,6 @@ protocol DeferTestProtocol {
214
218
var k : Klass { get }
215
219
216
220
static func getP( ) -> Self
217
- mutating func deferTestSuccess1( )
218
- mutating func deferTestSuccess2( )
219
- mutating func deferTestSuccess3( )
220
- mutating func deferTestFail1( )
221
- mutating func deferTestFail2( )
222
- mutating func deferTestFail3( )
223
- mutating func deferTestFail4( )
224
- mutating func deferTestFail5( )
225
- mutating func deferTestFail6( )
226
- mutating func deferTestFail7( )
227
221
}
228
222
229
223
extension DeferTestProtocol {
@@ -526,3 +520,36 @@ public func castTestIfLet2<T : P>(_ x : __owned EnumWithP<T>) {
526
520
print ( " no " )
527
521
}
528
522
}
523
+
524
+ ///////////////
525
+ // GEP Tests //
526
+ ///////////////
527
+
528
+ public func castAccess< T : P > ( _ x : __owned T) {
529
+ var x2 = x // expected-error {{'x2' used after being moved}}
530
+ x2 = x
531
+ let _ = _move ( x2) // expected-note {{move here}}
532
+ let _ = x2. k // expected-note {{use here}}
533
+ }
534
+
535
+ public func castAccess2< T : P > ( _ x : __owned T) {
536
+ var x2 = x // expected-error {{'x2' used after being moved}}
537
+ x2 = x
538
+ let _ = _move ( x2) // expected-note {{move here}}
539
+ let _ = x2. k. getOtherKlass ( ) // expected-note {{use here}}
540
+ }
541
+
542
+ /////////////////////////
543
+ // Partial Apply Tests //
544
+ /////////////////////////
545
+
546
+ // This makes sure we always fail if we are asked to check in a partial apply.
547
+ public func partialApplyTest< T : P > ( _ x: __owned T) {
548
+ var x2 = x
549
+ x2 = x
550
+ let _ = _move ( x2) // expected-error {{_move applied to value that the compiler does not support checking}}
551
+ let f = {
552
+ print ( x2)
553
+ }
554
+ f ( )
555
+ }
0 commit comments