diff --git a/lib/SIL/IR/SIL.cpp b/lib/SIL/IR/SIL.cpp index 6186d24c075e0..deff783aeda2b 100644 --- a/lib/SIL/IR/SIL.cpp +++ b/lib/SIL/IR/SIL.cpp @@ -249,6 +249,24 @@ static bool isTypeMetadataForLayoutAccessible(SILModule &M, SILType type) { if (type.is()) return true; + // - pack expansion types + if (auto expansionType = type.getAs()) { + auto patternType = SILType::getPrimitiveType(expansionType.getPatternType(), + type.getCategory()); + return isTypeMetadataForLayoutAccessible(M, patternType); + } + + // - lowered pack types + if (auto packType = type.getAs()) { + for (auto eltType : packType.getElementTypes()) { + if (!isTypeMetadataForLayoutAccessible( + M, SILType::getPrimitiveAddressType(eltType))) + return false; + } + + return true; + } + // Otherwise, check that we can fetch the type metadata. return M.isTypeMetadataAccessible(type.getASTType()); } diff --git a/test/IRGen/variadic_generic_captures.swift b/test/IRGen/variadic_generic_captures.swift index edca2eae4a93e..088dd2feef6a3 100644 --- a/test/IRGen/variadic_generic_captures.swift +++ b/test/IRGen/variadic_generic_captures.swift @@ -65,3 +65,8 @@ public func has_witness_table_pack2(t: repeat each T) -> () -> where repeat (each T).Element: Sequence { return { _ = (repeat (each T).Element.Element).self } } + +// https://github.com/apple/swift/issues/71455 +func f(t: (repeat each T)) { + let tup = (repeat ((each T).self, each t)) +}