@@ -270,9 +270,10 @@ static bool isPatternInvariantToExpansion(CanType patternType,
270
270
});
271
271
}
272
272
273
- static std::pair<GenericEnvironment*, SILType>
274
- deriveOpenedElementTypeForPackExpansion (SILGenModule &SGM,
275
- CanPackExpansionType expansion) {
273
+ std::pair<GenericEnvironment*, SILType>
274
+ SILGenFunction::createOpenedElementValueEnvironment (SILType expansionTy) {
275
+ auto expansion = expansionTy.castTo <PackExpansionType>();
276
+
276
277
// If the pattern type is invariant to the expansion, we don't need
277
278
// to open anything.
278
279
auto countArchetype = cast<PackArchetypeType>(expansion.getCountType ());
@@ -300,10 +301,9 @@ void SILGenFunction::emitPartialDestroyPack(SILLocation loc, SILValue packAddr,
300
301
unsigned componentIndex,
301
302
SILValue limitWithinComponent) {
302
303
auto packTy = packAddr->getType ().castTo <SILPackType>();
303
- auto packExpansionTy =
304
- cast<PackExpansionType>(packTy->getElementType (componentIndex));
305
304
306
- auto result = deriveOpenedElementTypeForPackExpansion (SGM, packExpansionTy);
305
+ auto result = createOpenedElementValueEnvironment (
306
+ packTy->getSILElementType (componentIndex));
307
307
auto elementEnv = result.first ;
308
308
auto elementTy = result.second ;
309
309
@@ -322,11 +322,8 @@ void SILGenFunction::emitPartialDestroyTuple(SILLocation loc,
322
322
CanPackType inducedPackType,
323
323
unsigned componentIndex,
324
324
SILValue limitWithinComponent) {
325
- auto tupleTy = tupleAddr->getType ().castTo <TupleType>();
326
- auto packExpansionTy =
327
- cast<PackExpansionType>(tupleTy.getElementType (componentIndex));
328
-
329
- auto result = deriveOpenedElementTypeForPackExpansion (SGM, packExpansionTy);
325
+ auto result = createOpenedElementValueEnvironment (
326
+ tupleAddr->getType ().getTupleElementType (componentIndex));
330
327
auto elementEnv = result.first ;
331
328
auto elementTy = result.second ;
332
329
0 commit comments