@@ -62,15 +62,15 @@ bool TuplePackMatcher::match() {
6262 // A pack expansion type on the left hand side absorbs all elements
6363 // from the right hand side up to the next mismatched label.
6464 auto lhsElt = lhsElts.front ();
65- if (lhsElt.getType ()->is <PackExpansionType>()) {
65+ if (auto *lhsExpansionType = lhsElt.getType ()->getAs <PackExpansionType>()) {
6666 lhsElts = lhsElts.slice (1 );
6767
6868 assert (lhsElts.empty () || lhsElts.front ().hasName () &&
6969 " Tuple element with pack expansion type cannot be followed "
7070 " by an unlabeled element" );
7171
7272 auto *rhs = gatherTupleElements (rhsElts, lhsElt.getName (), ctx);
73- pairs.emplace_back (lhsElt. getType (), rhs, idx++);
73+ pairs.emplace_back (lhsExpansionType-> getPatternType (), rhs, idx++);
7474 continue ;
7575 }
7676
@@ -82,15 +82,15 @@ bool TuplePackMatcher::match() {
8282 // A pack expansion type on the right hand side absorbs all elements
8383 // from the left hand side up to the next mismatched label.
8484 auto rhsElt = rhsElts.front ();
85- if (rhsElt.getType ()->is <PackExpansionType>()) {
85+ if (auto *rhsExpansionType = rhsElt.getType ()->getAs <PackExpansionType>()) {
8686 rhsElts = rhsElts.slice (1 );
8787
8888 assert (rhsElts.empty () || rhsElts.front ().hasName () &&
8989 " Tuple element with pack expansion type cannot be followed "
9090 " by an unlabeled element" );
9191
9292 auto *lhs = gatherTupleElements (lhsElts, rhsElt.getName (), ctx);
93- pairs.emplace_back (lhs, rhsElt. getType (), idx++);
93+ pairs.emplace_back (lhs, rhsExpansionType-> getPatternType (), idx++);
9494 continue ;
9595 }
9696
@@ -169,34 +169,38 @@ bool ParamPackMatcher::match() {
169169
170170 // If the left hand side is a single pack expansion type, bind it
171171 // to what remains of the right hand side.
172- if (lhsParams.size () == 1 &&
173- lhsParams[0 ].getPlainType ()->is <PackExpansionType>()) {
174- SmallVector<Type, 2 > rhsTypes;
175- for (auto rhsParam : rhsParams) {
176- // FIXME: Check rhs flags
177- rhsTypes.push_back (rhsParam.getPlainType ());
178- }
179- auto rhs = PackType::get (ctx, rhsTypes);
172+ if (lhsParams.size () == 1 ) {
173+ auto lhsType = lhsParams[0 ].getPlainType ();
174+ if (auto *lhsExpansionType = lhsType->getAs <PackExpansionType>()) {
175+ SmallVector<Type, 2 > rhsTypes;
176+ for (auto rhsParam : rhsParams) {
177+ // FIXME: Check rhs flags
178+ rhsTypes.push_back (rhsParam.getPlainType ());
179+ }
180+ auto rhs = PackType::get (ctx, rhsTypes);
180181
181- // FIXME: Check lhs flags
182- pairs.emplace_back (lhsParams[0 ].getPlainType (), rhs, prefixLength);
183- return false ;
182+ // FIXME: Check lhs flags
183+ pairs.emplace_back (lhsExpansionType->getPatternType (), rhs, prefixLength);
184+ return false ;
185+ }
184186 }
185187
186188 // If the right hand side is a single pack expansion type, bind it
187189 // to what remains of the left hand side.
188- if (rhsParams.size () == 1 &&
189- rhsParams[0 ].getPlainType ()->is <PackExpansionType>()) {
190- SmallVector<Type, 2 > lhsTypes;
191- for (auto lhsParam : lhsParams) {
192- // FIXME: Check lhs flags
193- lhsTypes.push_back (lhsParam.getPlainType ());
194- }
195- auto lhs = PackType::get (ctx, lhsTypes);
190+ if (rhsParams.size () == 1 ) {
191+ auto rhsType = rhsParams[0 ].getPlainType ();
192+ if (auto *rhsExpansionType = rhsType->getAs <PackExpansionType>()) {
193+ SmallVector<Type, 2 > lhsTypes;
194+ for (auto lhsParam : lhsParams) {
195+ // FIXME: Check lhs flags
196+ lhsTypes.push_back (lhsParam.getPlainType ());
197+ }
198+ auto lhs = PackType::get (ctx, lhsTypes);
196199
197- // FIXME: Check rhs flags
198- pairs.emplace_back (lhs, rhsParams[0 ].getPlainType (), prefixLength);
199- return false ;
200+ // FIXME: Check rhs flags
201+ pairs.emplace_back (lhs, rhsParams[0 ].getPlainType (), prefixLength);
202+ return false ;
203+ }
200204 }
201205
202206 // Otherwise, all remaining possibilities are invalid:
0 commit comments