Skip to content

Commit c4e30e1

Browse files
authored
Merge pull request #64884 from nate-chandler/cherrypick/release/5.9/typelowering-lexicality-pack
5.9: [TypeLowering] NFC: Fix lexicality verification for packs and tuples.
2 parents 8b64bfe + 9f2419d commit c4e30e1

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

lib/SIL/IR/TypeLowering.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2758,16 +2758,16 @@ bool TypeConverter::visitAggregateLeaves(
27582758
packIndex);
27592759
}
27602760
} else if (auto tupleTy = ty->getAs<TupleType>()) {
2761-
for (unsigned tupleIndex = 0, num = tupleTy->getNumElements();
2762-
tupleIndex < num; ++tupleIndex) {
2763-
auto origElementTy = origTy.getTupleElementType(tupleIndex);
2764-
auto substElementTy =
2765-
tupleTy->getElementType(tupleIndex)->getCanonicalType();
2766-
substElementTy =
2767-
computeLoweredRValueType(context, origElementTy, substElementTy);
2768-
insertIntoWorklist(substElementTy, origElementTy, nullptr,
2769-
tupleIndex);
2770-
}
2761+
unsigned tupleIndex = 0;
2762+
origTy.forEachExpandedTupleElement(
2763+
CanTupleType(tupleTy),
2764+
[&](auto origElementTy, auto substElementTy, auto element) {
2765+
substElementTy =
2766+
substOpaqueTypesWithUnderlyingTypes(substElementTy, context);
2767+
insertIntoWorklist(substElementTy, origElementTy, nullptr,
2768+
tupleIndex);
2769+
++tupleIndex;
2770+
});
27712771
} else if (auto *decl = ty->getStructOrBoundGenericStruct()) {
27722772
for (auto *structField : decl->getStoredProperties()) {
27732773
auto subMap = ty->getContextSubstitutionMap(&M, decl);

test/SILGen/variadic-generic-tuples.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,14 @@ func callVariadicMemberwiseInit() -> MemberwiseTupleHolder<Int, String> {
284284
return MemberwiseTupleHolder(content: (0, "hello"))
285285
}
286286

287+
@_eagerMove struct MyString {
288+
var guts: AnyObject
289+
}
290+
291+
func callVariadicMemberwiseInit(_ ms: MyString) -> MemberwiseTupleHolder<Int, MyString> {
292+
return MemberwiseTupleHolder(content: (0, ms))
293+
}
294+
287295
// rdar://107151145: when we tuple-destructure a black hole
288296
// initialization, the resulting element initializations need to
289297
// handle pack expansion initialization

0 commit comments

Comments
 (0)