Skip to content

Commit 770e6f9

Browse files
committed
AST: Correct '(each T).A' output for archetypes
isParameterPack() is always false for an archetype; we must test for a PackArchetypeType here instead.
1 parent a6c99bd commit 770e6f9

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

lib/AST/ASTPrinter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6244,7 +6244,7 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
62446244
if (param->isParameterPack())
62456245
return false;
62466246
} else if (auto archetype = dyn_cast<ArchetypeType>(T.getPointer())) {
6247-
if (archetype->isParameterPack())
6247+
if (isa<PackArchetypeType>(archetype))
62486248
return false;
62496249
if (Options.PrintForSIL && isa<LocalArchetypeType>(archetype))
62506250
return false;

test/Constraints/pack-expansion-expressions.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func forEachEach<each C, U>(c: repeat each C, function: (U) -> Void)
7474
// expected-error@-1{{same-element requirements are not yet supported}}
7575

7676
_ = (repeat (each c).forEach(function))
77-
// expected-error@-1 {{cannot convert value of type '(U) -> Void' to expected argument type '(each C.Element) throws -> Void'}}
77+
// expected-error@-1 {{cannot convert value of type '(U) -> Void' to expected argument type '((each C).Element) throws -> Void'}}
7878
}
7979

8080
func typeReprPacks<each T: ExpressibleByIntegerLiteral>(_ t: repeat each T) {

test/IRGen/variadic_generic_functions.sil

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ sil @fc : $<each T : P> () -> () {}
7070
// CHECK-SAME: [[INT]] %0,
7171
// CHECK-SAME: ptr %"each T",
7272
// CHECK-SAME: ptr %"each T.PA",
73-
// CHECK-SAME: ptr %"each T.A.P")
74-
// CHECK: call swiftcc void @f1c([[INT]] %0, ptr %"each T", ptr %"each T.PA", ptr %"each T.A.P")
73+
// CHECK-SAME: ptr %"(each T).A.P")
74+
// CHECK: call swiftcc void @f1c([[INT]] %0, ptr %"each T", ptr %"each T.PA", ptr %"(each T).A.P")
7575
sil @f1 : $<each T : PA where repeat (each T).A : P> () -> () {
7676
%f1c = function_ref @f1c : $@convention(thin) <each T : PA where repeat (each T).A : P> () -> ()
7777
apply %f1c<Pack{repeat each T}>() : $@convention(thin) <each T : PA where repeat (each T).A : P> () -> ()
@@ -105,7 +105,7 @@ sil @associatedtype_with_added_conformance_callee : $<each T : Q> () -> () {}
105105
// CHECK-SAME: [[INT]] [[SHAPE:%[^,]+]],
106106
// CHECK-SAME: ptr %"each T",
107107
// CHECK-SAME: ptr %"each T.PA",
108-
// CHECK-SAME: ptr %"each T.A.QA",
108+
// CHECK-SAME: ptr %"(each T).A.QA",
109109
// CHECK-SAME: ptr [[ASSOCIATEDTYPES_CONFORMANCES_TO_Q:%[^,]+]])
110110
// CHECK: [[ASSOCIATEDTYPES:%[^,]+]] = alloca ptr, [[INT]] [[SHAPE]]
111111
// CHECK: call swiftcc void @associatedtype_with_added_conformance_2_callee(
@@ -147,15 +147,15 @@ sil @associatedtype_with_forwarded_conformance_1_callee : $<each T : Q> () -> ()
147147
// CHECK-SAME: [[INT]] [[SHAPE:%[^,]+]],
148148
// CHECK-SAME: ptr %"each T",
149149
// CHECK-SAME: ptr %"each T.PA",
150-
// CHECK-SAME: ptr %"each T.A.Q")
150+
// CHECK-SAME: ptr %"(each T).A.Q")
151151
// CHECK: [[GEN1_TYPES:%[^,]+]] = alloca ptr, [[INT]] [[SHAPE]]
152152
// CHECK: [[STORED_STACK_LOC:%[^,]+]] = call ptr @llvm.stacksave()
153153
// CHECK: [[GEN1_CONFORMANCES_TO_PA:%[^,]+]] = alloca ptr, [[INT]] [[SHAPE]]
154154
// CHECK: call swiftcc void @generictype_with_forwarded_conformance_2_callee(
155155
// CHECK-SAME: [[INT]] [[SHAPE]],
156156
// CHECK-SAME: ptr [[GEN1_TYPES]],
157157
// CHECK-SAME: ptr [[GEN1_CONFORMANCES_TO_PA]],
158-
// CHECK-SAME: ptr %"each T.A.Q")
158+
// CHECK-SAME: ptr %"(each T).A.Q")
159159
// CHECK: call void @llvm.stackrestore(ptr [[STORED_STACK_LOC]])
160160
sil @generictype_with_forwarded_conformance_2 : $<each T : PA where repeat (each T).A : Q>() -> () {
161161
%callee = function_ref @generictype_with_forwarded_conformance_2_callee : $@convention(thin) <each T : PA where repeat (each T).A : Q> () -> ()
@@ -170,15 +170,15 @@ sil @generictype_with_forwarded_conformance_2_callee : $<each T : PA where repea
170170
// CHECK-SAME: [[INT]] [[SHAPE:%[^,]+]],
171171
// CHECK-SAME: ptr %"each T",
172172
// CHECK-SAME: ptr %"each T.PA",
173-
// CHECK-SAME: ptr %"each T.A.Q")
173+
// CHECK-SAME: ptr %"(each T).A.Q")
174174
// CHECK: [[GEN1_GEN1_TYPES:%[^,]+]] = alloca ptr, [[INT]] [[SHAPE]]
175175
// CHECK: [[STORED_STACK_LOC:%[^,]+]] = call ptr @llvm.stacksave()
176176
// CHECK: [[GEN1_GEN1_CONFORMANCES_TO_PA:%[^,]+]] = alloca ptr, [[INT]] [[SHAPE]]
177177
// CHECK: call swiftcc void @generic_with_forwarded_conformance_3_callee(
178178
// CHECK-SAME: [[INT]] [[SHAPE]],
179179
// CHECK-SAME: ptr [[GEN1_GEN1_TYPES]],
180180
// CHECK-SAME: ptr [[GEN1_GEN1_CONFORMANCES_TO_PA]],
181-
// CHECK-SAME: ptr %"each T.A.Q")
181+
// CHECK-SAME: ptr %"(each T).A.Q")
182182
// CHECK: call void @llvm.stackrestore(ptr [[STORED_STACK_LOC]])
183183
sil @generic_with_forwarded_conformance_3 : $<each T : PA where repeat (each T).A : Q> () -> () {
184184
%callee = function_ref @generic_with_forwarded_conformance_3_callee : $@convention(thin) <each T : PA where repeat (each T).A : Q> () -> ()

test/SILGen/variadic-generic-tuples.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,8 +358,8 @@ func testStructOfLoadableTuple() -> StructOfLoadableTuple<Int> {
358358
// The verifier had some home-grown type-lowering logic that didn't
359359
// know about pack expansions.
360360
// CHECK-LABEL: sil {{.*}}@$s4main22testExistentialErasureyyxxQpRvzlF1gL_yyqd__qd__QpRvzRvd__r__lF :
361-
// CHECK: [[T0:%.*]] = init_existential_addr {{.*}} : $*Any, $(repeat each T.Type)
362-
// CHECK: tuple_pack_element_addr {{.*}} of [[T0]] : $*(repeat @thick each T.Type) as $*@thick (@pack_element("{{.*}}") each T).Type
361+
// CHECK: [[T0:%.*]] = init_existential_addr {{.*}} : $*Any, $(repeat (each T).Type)
362+
// CHECK: tuple_pack_element_addr {{.*}} of [[T0]] : $*(repeat @thick (each T).Type) as $*@thick (@pack_element("{{.*}}") each T).Type
363363
func testExistentialErasure<each T>(_: repeat each T) {
364364
func g<each U>(_: repeat each U) {
365365
print((repeat (each T).self))

0 commit comments

Comments
 (0)