Skip to content

Commit 2a84083

Browse files
committed
Add regression test to close #43211
1 parent e487acf commit 2a84083

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

test/stdlib/Reflection.swift

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,5 +194,40 @@ sanePointerString.deallocate()
194194
var rawPointer = unsafeBitCast(0 as Int, to: Builtin.RawPointer.self)
195195
dump(rawPointer)
196196

197+
// https://github.com/apple/swift/issues/43211
198+
// CHECK-LABEL: {{^}}weak with dynamic value{{$}}
199+
print("weak with dynamic value")
200+
do {
201+
class Child {}
202+
class Example {
203+
weak var value: Child?
204+
}
205+
206+
var c: Child? = Child()
207+
let e = Example()
208+
e.value = c
209+
210+
// CHECK-NEXT: c1: Optional(Reflection.{{.*}}.Child)
211+
// CHECK-NEXT: some: Reflection.{{.*}}.Child #0
212+
dump(c, name: "c1")
213+
// CHECK-NEXT: e1: Reflection.{{.*}}.Example #0
214+
// CHECK-NEXT: value: Optional(Reflection.{{.*}}.Child)
215+
// CHECK-NEXT: some: Reflection.{{.*}}.Child #1
216+
dump(e, name: "e1")
217+
// CHECK-NEXT: value1: Optional(Reflection.{{.*}}.Child)
218+
// CHECK-NEXT: some: Reflection.{{.*}}.Child #0
219+
dump(e.value, name: "value1")
220+
221+
c = nil
222+
223+
// CHECK-NEXT: c2: nil
224+
dump(c, name: "c2")
225+
// CHECK-NEXT: e2: Reflection.{{.*}}.Example #0
226+
// CHECK-NEXT: value: nil
227+
dump(e, name: "e2")
228+
// CHECK-NEXT: value2: nil
229+
dump(e.value, name: "value2")
230+
}
231+
197232
// CHECK-LABEL: and now our song is done
198233
print("and now our song is done")

0 commit comments

Comments
 (0)