Skip to content

Commit d3540b4

Browse files
authored
Merge pull request #71376 from simanerush/pack-argument-fix
SIL: Adjust `isTypeMetadataForLayoutAccessible()` to visit more lowered positions
2 parents a5c659b + ce9b362 commit d3540b4

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

lib/SIL/IR/SIL.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,24 @@ static bool isTypeMetadataForLayoutAccessible(SILModule &M, SILType type) {
256256
if (type.is<AnyMetatypeType>())
257257
return true;
258258

259+
// - pack expansion types
260+
if (auto expansionType = type.getAs<PackExpansionType>()) {
261+
auto patternType = SILType::getPrimitiveType(expansionType.getPatternType(),
262+
type.getCategory());
263+
return isTypeMetadataForLayoutAccessible(M, patternType);
264+
}
265+
266+
// - lowered pack types
267+
if (auto packType = type.getAs<SILPackType>()) {
268+
for (auto eltType : packType.getElementTypes()) {
269+
if (!isTypeMetadataForLayoutAccessible(
270+
M, SILType::getPrimitiveAddressType(eltType)))
271+
return false;
272+
}
273+
274+
return true;
275+
}
276+
259277
// Otherwise, check that we can fetch the type metadata.
260278
return M.isTypeMetadataAccessible(type.getASTType());
261279
}

test/IRGen/variadic_generic_captures.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,8 @@ public func has_witness_table_pack2<each T: Sequence>(t: repeat each T) -> () ->
6565
where repeat (each T).Element: Sequence {
6666
return { _ = (repeat (each T).Element.Element).self }
6767
}
68+
69+
// https://github.com/apple/swift/issues/71455
70+
func f<each T>(t: (repeat each T)) {
71+
let tup = (repeat ((each T).self, each t))
72+
}

0 commit comments

Comments
 (0)