From 368721ef5c7c9f694425dada26fc0ed8c7f2a1eb Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 2 Jan 2024 17:08:22 -0500 Subject: [PATCH 1/2] SIL: Adjust isTypeMetadataForLayoutAccessible() to visit more lowered positions Fixes part of https://github.com/apple/swift/issues/67645, rdar://119267393 --- lib/SIL/IR/SIL.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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()); } From ce9b362a61f719956e1d1106a0a54a8257334e73 Mon Sep 17 00:00:00 2001 From: Sima Nerush <2002ssn@gmail.com> Date: Thu, 8 Feb 2024 00:14:48 -0800 Subject: [PATCH 2/2] [NFC] Tests: Add a test case for #71376 --- test/IRGen/variadic_generic_captures.swift | 5 +++++ 1 file changed, 5 insertions(+) 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)) +}