Skip to content

Commit 43eb71c

Browse files
committed
ASTPrinter: Tweak PackExpansionType printing
1 parent 272ada5 commit 43eb71c

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

lib/AST/ASTPrinter.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6075,12 +6075,24 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
60756075
}
60766076

60776077
void visitPackExpansionType(PackExpansionType *T) {
6078+
SmallVector<Type, 2> rootParameterPacks;
6079+
T->getPatternType()->getTypeParameterPacks(rootParameterPacks);
6080+
6081+
if (rootParameterPacks.empty() &&
6082+
(T->getCountType()->isParameterPack() ||
6083+
T->getCountType()->is<PackArchetypeType>())) {
6084+
Printer << "/* shape: ";
6085+
visit(T->getCountType());
6086+
Printer << " */ ";
6087+
}
6088+
60786089
Printer << "repeat ";
6090+
60796091
visit(T->getPatternType());
60806092
}
60816093

60826094
void visitPackElementType(PackElementType *T) {
6083-
Printer << "@level(" << T->getLevel() << ") ";
6095+
Printer << "/* level: " << T->getLevel() << " */ ";
60846096
visit(T->getPackType());
60856097
}
60866098

test/Constraints/pack-expansion-expressions.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -527,8 +527,8 @@ do {
527527
func test_pack_expansion_to_void_conv_for_closure_result<each T>(x: repeat each T) {
528528
let _: () -> Void = { repeat print(each x) } // Ok
529529
let _: () -> Void = { (repeat print(each x)) } // Ok
530-
let _: (Int) -> Void = { repeat ($0, print(each x)) } // expected-warning {{'repeat (Int, ())' is unused}}
531-
let _: (Int, String) -> Void = { ($0, repeat ($1, print(each x))) } // expected-warning {{'(Int, repeat (String, ()))' is unused}}
530+
let _: (Int) -> Void = { repeat ($0, print(each x)) } // expected-warning {{expression of type '/* shape: each T */ repeat (Int, ())' is unused}}
531+
let _: (Int, String) -> Void = { ($0, repeat ($1, print(each x))) } // expected-warning {{expression of type '(Int, /* shape: each T */ repeat (String, ()))' is unused}}
532532
}
533533

534534
// rdar://109539394 - crash on passing multiple variadic lists to singly variadic callee

test/SILGen/variadic-generic-tuples.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ func takeAny(_ arg: Any) {}
1313
// CHECK-NEXT: [[IDX_EQ_LEN:%.*]] = builtin "cmp_eq_Word"([[IDX]] : $Builtin.Word, [[LEN]] : $Builtin.Word) : $Builtin.Int1
1414
// CHECK-NEXT: cond_br [[IDX_EQ_LEN]], bb3, bb2
1515
// CHECK: bb2:
16-
// CHECK-NEXT: [[INDEX:%.*]] = dynamic_pack_index [[IDX]] of $Pack{repeat ()}
16+
// CHECK-NEXT: [[INDEX:%.*]] = dynamic_pack_index [[IDX]] of $Pack{/* shape: each T */ repeat ()}
1717
// CHECK-NEXT: open_pack_element [[INDEX]] of <each T> at <Pack{repeat each T}>, shape $each T, uuid [[UUID:".*"]]
1818
// CHECK-NEXT: [[TEMP:%.*]] = alloc_stack $Any
1919
// CHECK-NEXT: [[ELT_ADDR:%.*]] = pack_element_get [[INDEX]] of %0 : $*Pack{repeat each T} as $*@pack_element([[UUID]]) each T

0 commit comments

Comments
 (0)