@@ -2534,24 +2534,21 @@ static CanTupleType computeLoweredTupleType(TypeConverter &tc,
2534
2534
TypeExpansionContext context,
2535
2535
AbstractionPattern origType,
2536
2536
CanTupleType substType) {
2537
- assert (origType. matchesTuple ( substType)) ;
2537
+ if ( substType-> getNumElements () == 0 ) return substType ;
2538
2538
2539
- // Does the lowered tuple type differ from the substituted type in
2540
- // any interesting way?
2541
2539
bool changed = false ;
2542
2540
SmallVector<TupleTypeElt, 4 > loweredElts;
2543
2541
loweredElts.reserve (substType->getNumElements ());
2544
2542
2545
- for (auto i : indices (substType->getElementTypes ())) {
2546
- auto origEltType = origType.getTupleElementType (i);
2547
- auto substEltType = substType.getElementType (i);
2548
-
2549
- CanType loweredTy =
2550
- tc.getLoweredRValueType (context, origEltType, substEltType);
2551
- changed = (changed || substEltType != loweredTy);
2552
-
2553
- loweredElts.push_back (substType->getElement (i).getWithType (loweredTy));
2554
- }
2543
+ origType.forEachExpandedTupleElement (substType,
2544
+ [&](AbstractionPattern origEltType,
2545
+ CanType substEltType,
2546
+ const TupleTypeElt &elt) {
2547
+ auto loweredTy =
2548
+ tc.getLoweredRValueType (context, origEltType, substEltType);
2549
+ if (loweredTy != substEltType) changed = true ;
2550
+ loweredElts.push_back (elt.getWithType (loweredTy));
2551
+ });
2555
2552
2556
2553
if (!changed) return substType;
2557
2554
@@ -3014,12 +3011,8 @@ TypeConverter::computeLoweredRValueType(TypeExpansionContext forExpansion,
3014
3011
substPatternType);
3015
3012
changed |= (loweredSubstPatternType != substPatternType);
3016
3013
3017
- CanType substCountType = substPackExpansionType.getCountType ();
3018
- CanType loweredSubstCountType = TC.getLoweredRValueType (
3019
- forExpansion,
3020
- origType.getPackExpansionCountType (),
3021
- substCountType);
3022
- changed |= (loweredSubstCountType != substCountType);
3014
+ // Count types are AST types and are not lowered.
3015
+ CanType loweredSubstCountType = substPackExpansionType.getCountType ();
3023
3016
3024
3017
if (!changed)
3025
3018
return substPackExpansionType;
0 commit comments