@@ -2534,24 +2534,21 @@ static CanTupleType computeLoweredTupleType(TypeConverter &tc,
25342534 TypeExpansionContext context,
25352535 AbstractionPattern origType,
25362536 CanTupleType substType) {
2537- assert (origType. matchesTuple ( substType)) ;
2537+ if ( substType-> getNumElements () == 0 ) return substType ;
25382538
2539- // Does the lowered tuple type differ from the substituted type in
2540- // any interesting way?
25412539 bool changed = false ;
25422540 SmallVector<TupleTypeElt, 4 > loweredElts;
25432541 loweredElts.reserve (substType->getNumElements ());
25442542
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+ });
25552552
25562553 if (!changed) return substType;
25572554
@@ -3014,12 +3011,8 @@ TypeConverter::computeLoweredRValueType(TypeExpansionContext forExpansion,
30143011 substPatternType);
30153012 changed |= (loweredSubstPatternType != substPatternType);
30163013
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 ();
30233016
30243017 if (!changed)
30253018 return substPackExpansionType;
0 commit comments