Skip to content

Commit ed28d8e

Browse files
committed
Add a test case where the innermost type has no generic parameters
1 parent 16c0729 commit ed28d8e

File tree

1 file changed

+40
-2
lines changed

1 file changed

+40
-2
lines changed

validation-test/Reflection/reflect_nested_generic.swift

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ reflect(enum: Outer1.C<Void>.Inner.S<(Int,Int)>?.none)
3737

3838
//CHECK: Type info:
3939

40+
// This is the layout for 64-bit targets (Note, this example
41+
// has no pointer-based elements, so we don't need to distinguish
42+
// extra inhabitants for platforms with varying pointer layouts.)
43+
4044
//X64-NEXT: (single_payload_enum size=19 alignment=8 stride=24 num_extra_inhabitants=0 bitwise_takable=1
4145
//X64-NEXT: (case name=some index=0 offset=0
4246
//X64-NEXT: (struct size=18 alignment=8 stride=24 num_extra_inhabitants=0 bitwise_takable=1
@@ -60,7 +64,7 @@ reflect(enum: Outer1.C<Void>.Inner.S<(Int,Int)>?.none)
6064
//X64-NEXT: (case name=none index=1)))))
6165
//X64-NEXT: (case name=none index=1))
6266

63-
//TODO: X32
67+
//TODO: Work out the layout for 32-bit targets
6468

6569
//CHECK: Mangled name: $s22reflect_nested_generic6Outer1O1CC1SVy_yt_Si_SitGSg
6670
//CHECK-NEXT: Demangled name: Swift.Optional<reflect_nested_generic.Outer1.C<()>.S<(Swift.Int, Swift.Int)>>
@@ -78,6 +82,9 @@ struct Outer2 {
7882
enum E<T: P> {
7983
struct Inner {
8084
enum F<U: P> {
85+
struct Innerer {
86+
var u: U? = nil
87+
}
8188
case u(U)
8289
case a
8390
case b
@@ -96,7 +103,7 @@ reflect(enum: Outer2.E<S1>.Inner.F<S2>.b)
96103
//CHECK-NEXT: (bound_generic_enum reflect_nested_generic.Outer2.E
97104
//CHECK-NEXT: (struct reflect_nested_generic.S1)))
98105

99-
// Note: layout here is correct for both 32- and 64-bit platforms
106+
// Note: layout here is same for both 32- and 64-bit platforms
100107

101108
//CHECK: Type info:
102109
//CHECK-NEXT: (single_payload_enum size=1 alignment=1 stride=1 num_extra_inhabitants=0 bitwise_takable=1
@@ -111,6 +118,37 @@ reflect(enum: Outer2.E<S1>.Inner.F<S2>.b)
111118
//CHECK: Enum value:
112119
//CHECK-NEXT: (enum_value name=b index=2)
113120

121+
reflect(enum: Outer2.E<S1>.Inner.F<S2>.Innerer?.none)
122+
123+
//CHECK: Reflecting an enum.
124+
//CHECK-NEXT: Instance pointer in child address space: 0x{{[0-9a-fA-F]+}}
125+
//CHECK-NEXT: Type reference:
126+
//CHECK-NEXT: (bound_generic_enum Swift.Optional
127+
//CHECK-NEXT: (bound_generic_struct reflect_nested_generic.Outer2.E.Inner.F.Innerer
128+
//CHECK-NEXT: (bound_generic_enum reflect_nested_generic.Outer2.E.Inner.F
129+
//CHECK-NEXT: (struct reflect_nested_generic.S2)
130+
//CHECK-NEXT: (bound_generic_enum reflect_nested_generic.Outer2.E
131+
//CHECK-NEXT: (struct reflect_nested_generic.S1)))))
132+
133+
// This layout is the same for 32-bit or 64-bit platforms
134+
135+
//CHECK: Type info:
136+
//CHECK-NEXT: (single_payload_enum size=2 alignment=1 stride=2 num_extra_inhabitants=0 bitwise_takable=1
137+
//CHECK-NEXT: (case name=some index=0 offset=0
138+
//CHECK-NEXT: (struct size=1 alignment=1 stride=1 num_extra_inhabitants=0 bitwise_takable=1
139+
//CHECK-NEXT: (field name=u offset=0
140+
//CHECK-NEXT: (single_payload_enum size=1 alignment=1 stride=1 num_extra_inhabitants=0 bitwise_takable=1
141+
//CHECK-NEXT: (case name=some index=0 offset=0
142+
//CHECK-NEXT: (struct size=0 alignment=1 stride=1 num_extra_inhabitants=0 bitwise_takable=1))
143+
//CHECK-NEXT: (case name=none index=1)))))
144+
//CHECK-NEXT: (case name=none index=1))
145+
146+
//CHECK-NEXT: Mangled name: $s22reflect_nested_generic6Outer2V1EO1FO7InnererVy_AA2S1V_AA2S2V_GSg
147+
//CHECK-NEXT: Demangled name: Swift.Optional<reflect_nested_generic.Outer2.E<reflect_nested_generic.S1>.F<reflect_nested_generic.S2>.Innerer<>>
148+
149+
//CHECK: Enum value:
150+
//CHECK-NEXT: (enum_value name=none index=1)
151+
114152
doneReflecting()
115153

116154
// CHECK: Done.

0 commit comments

Comments
 (0)