Skip to content

Commit 1e94e3f

Browse files
committed
SwiftRemoteMirror: Add a test for unowned-self captures
NFC.
1 parent a7fd48a commit 1e94e3f

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

validation-test/Reflection/functions.swift

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,12 @@ class C {
8282
print(self)
8383
}
8484
}
85+
86+
func captureUnownedSelf() -> () -> () {
87+
return { [unowned self] in
88+
print(self)
89+
}
90+
}
8591
}
8692

8793
func generic<T : P, U, V : C>(x: T, y: U, z: V, i: Int) {
@@ -504,4 +510,25 @@ reflect(function: C().captureWeakSelf())
504510
// CHECK-32-NEXT: (field offset=12
505511
// CHECK-32-NEXT: (reference kind=weak refcounting=native)))
506512

513+
reflect(function: C().captureUnownedSelf())
514+
// CHECK-64: Reflecting an object.
515+
// CHECK-64: Instance pointer in child address space: 0x{{[0-9a-fA-F]+}}
516+
// CHECK-64: Type reference:
517+
// CHECK-64: (builtin Builtin.NativeObject)
518+
519+
// CHECK-64: Type info:
520+
// CHECK-64: (closure_context size=24 alignment=8 stride=24 num_extra_inhabitants=0
521+
// CHECK-64-NEXT: (field offset=16
522+
// CHECK-64-NEXT: (reference kind=unowned refcounting=native)))
523+
524+
// CHECK-32: Reflecting an object.
525+
// CHECK-32: Instance pointer in child address space: 0x{{[0-9a-fA-F]+}}
526+
// CHECK-32: Type reference:
527+
// CHECK-32: (builtin Builtin.NativeObject)
528+
529+
// CHECK-32: Type info:
530+
// CHECK-32: (closure_context size=16 alignment=4 stride=16 num_extra_inhabitants=0
531+
// CHECK-32-NEXT: (field offset=12
532+
// CHECK-32-NEXT: (reference kind=unowned refcounting=native)))
533+
507534
doneReflecting()

0 commit comments

Comments
 (0)