|
| 1 | +// RUN: %empty-directory(%t) |
| 2 | +// RUN: %target-build-swift -lswiftSwiftReflectionTest %s -o %t/reflect_Class_nested_generic.swift |
| 3 | +// RUN: %target-codesign %t/reflect_Class_nested_generic.swift |
| 4 | + |
| 5 | +// RUN: %target-run %target-swift-reflection-test %t/reflect_Class_nested_generic.swift | %FileCheck %s --check-prefix=CHECK-%target-ptrsize |
| 6 | + |
| 7 | +// REQUIRES: reflection_test_support |
| 8 | +// REQUIRES: executable_test |
| 9 | +// UNSUPPORTED: use_os_stdlib |
| 10 | + |
| 11 | +import SwiftReflectionTest |
| 12 | + |
| 13 | +class HoldsNonNamespacedNestedStruct { |
| 14 | + struct NamespacedNestingStruct<T> { |
| 15 | + let nested: T |
| 16 | + } |
| 17 | + |
| 18 | + let nestedField = NamespacedNestingStruct<Int>(nested: 1) |
| 19 | +} |
| 20 | + |
| 21 | +reflect(object: HoldsNonNamespacedNestedStruct()) |
| 22 | + |
| 23 | +// CHECK: Reflecting an object. |
| 24 | +// CHECK-NEXT: Instance pointer in child address space: 0x{{[0-9a-fA-F]+}} |
| 25 | +// CHECK-NEXT: Type reference: |
| 26 | +// CHECK-NEXT: (class reflect_Class_nested_generic.HoldsNonNamespacedNestedStruct) |
| 27 | + |
| 28 | +// CHECK-64: Type info: |
| 29 | +// CHECK-64-NEXT: (class_instance size=24 alignment=8 stride=24 num_extra_inhabitants=0 bitwise_takable=1 |
| 30 | +// CHECK-64-NEXT: (field name=nestedField offset=16 |
| 31 | +// CHECK-64-NEXT: (struct size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1 |
| 32 | +// CHECK-64-NEXT: (field name=nested offset=0 |
| 33 | +// CHECK-64-NEXT: (struct size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1 |
| 34 | +// CHECK-64-NEXT: (field name=_value offset=0 |
| 35 | +// CHECK-64-NEXT: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1))))))) |
| 36 | + |
| 37 | +struct NestingStruct<T> { |
| 38 | + let nested: T |
| 39 | +} |
| 40 | +class HoldsNamespacedNestedStruct { |
| 41 | + let nestedField = NestingStruct<Int>(nested: 1) |
| 42 | +} |
| 43 | + |
| 44 | +reflect(object: HoldsNamespacedNestedStruct()) |
| 45 | + |
| 46 | +// CHECK: Reflecting an object. |
| 47 | +// CHECK-NEXT: Instance pointer in child address space: 0x{{[0-9a-fA-F]+}} |
| 48 | +// CHECK-NEXT: Type reference: |
| 49 | +// CHECK-NEXT: (class reflect_Class_nested_generic.HoldsNamespacedNestedStruct) |
| 50 | + |
| 51 | +// CHECK-64: Type info: |
| 52 | +// CHECK-64-NEXT: (class_instance size=24 alignment=8 stride=24 num_extra_inhabitants=0 bitwise_takable=1 |
| 53 | +// CHECK-64-NEXT: (field name=nestedField offset=16 |
| 54 | +// CHECK-64-NEXT: (struct size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1 |
| 55 | +// CHECK-64-NEXT: (field name=nested offset=0 |
| 56 | +// CHECK-64-NEXT: (struct size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1 |
| 57 | +// CHECK-64-NEXT: (field name=_value offset=0 |
| 58 | +// CHECK-64-NEXT: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1))))))) |
| 59 | + |
| 60 | +// CHECK-32: Type info: |
| 61 | +// FIXME: actual 32-bit layout here |
| 62 | + |
| 63 | +struct ContainerStruct<T> { |
| 64 | + struct Foo { |
| 65 | + struct Bar { |
| 66 | + struct NestingStruct<U> { |
| 67 | + let t: T |
| 68 | + let u: U |
| 69 | + } |
| 70 | + } |
| 71 | + } |
| 72 | +} |
| 73 | +class HoldsNamespacedContainedNestedStruct { |
| 74 | + let nestedField = ContainerStruct<Int>.Foo.Bar.NestingStruct<Double>(t: 1, u: 1) |
| 75 | +} |
| 76 | + |
| 77 | +reflect(object: HoldsNamespacedContainedNestedStruct()) |
| 78 | + |
| 79 | +// CHECK: Reflecting an object. |
| 80 | +// CHECK-NEXT: Instance pointer in child address space: 0x{{[0-9a-fA-F]+}} |
| 81 | +// CHECK-NEXT: Type reference: |
| 82 | +// CHECK-NEXT: (class reflect_Class_nested_generic.HoldsNamespacedContainedNestedStruct) |
| 83 | + |
| 84 | +// CHECK-64: Type info: |
| 85 | +// CHECK-64-NEXT: (class_instance size=32 alignment=8 stride=32 num_extra_inhabitants=0 bitwise_takable=1 |
| 86 | +// CHECK-64-NEXT: (field name=nestedField offset=16 |
| 87 | +// CHECK-64-NEXT: (struct size=16 alignment=8 stride=16 num_extra_inhabitants=0 bitwise_takable=1 |
| 88 | +// CHECK-64-NEXT: (field name=t offset=0 |
| 89 | +// CHECK-64-NEXT: (struct size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1 |
| 90 | +// CHECK-64-NEXT: (field name=_value offset=0 |
| 91 | +// CHECK-64-NEXT: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1)))) |
| 92 | +// CHECK-64-NEXT: (field name=u offset=8 |
| 93 | +// CHECK-64-NEXT: (struct size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1 |
| 94 | +// CHECK-64-NEXT: (field name=_value offset=0 |
| 95 | +// CHECK-64-NEXT: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1))))))) |
| 96 | + |
| 97 | + |
| 98 | +doneReflecting() |
| 99 | + |
| 100 | +// CHECK-64: Done. |
| 101 | + |
| 102 | +// CHECK-32: Done. |
0 commit comments