@@ -62,15 +62,15 @@ bool TuplePackMatcher::match() {
62
62
// A pack expansion type on the left hand side absorbs all elements
63
63
// from the right hand side up to the next mismatched label.
64
64
auto lhsElt = lhsElts.front ();
65
- if (lhsElt.getType ()->is <PackExpansionType>()) {
65
+ if (auto *lhsExpansionType = lhsElt.getType ()->getAs <PackExpansionType>()) {
66
66
lhsElts = lhsElts.slice (1 );
67
67
68
68
assert (lhsElts.empty () || lhsElts.front ().hasName () &&
69
69
" Tuple element with pack expansion type cannot be followed "
70
70
" by an unlabeled element" );
71
71
72
72
auto *rhs = gatherTupleElements (rhsElts, lhsElt.getName (), ctx);
73
- pairs.emplace_back (lhsElt. getType (), rhs, idx++);
73
+ pairs.emplace_back (lhsExpansionType-> getPatternType (), rhs, idx++);
74
74
continue ;
75
75
}
76
76
@@ -82,15 +82,15 @@ bool TuplePackMatcher::match() {
82
82
// A pack expansion type on the right hand side absorbs all elements
83
83
// from the left hand side up to the next mismatched label.
84
84
auto rhsElt = rhsElts.front ();
85
- if (rhsElt.getType ()->is <PackExpansionType>()) {
85
+ if (auto *rhsExpansionType = rhsElt.getType ()->getAs <PackExpansionType>()) {
86
86
rhsElts = rhsElts.slice (1 );
87
87
88
88
assert (rhsElts.empty () || rhsElts.front ().hasName () &&
89
89
" Tuple element with pack expansion type cannot be followed "
90
90
" by an unlabeled element" );
91
91
92
92
auto *lhs = gatherTupleElements (lhsElts, rhsElt.getName (), ctx);
93
- pairs.emplace_back (lhs, rhsElt. getType (), idx++);
93
+ pairs.emplace_back (lhs, rhsExpansionType-> getPatternType (), idx++);
94
94
continue ;
95
95
}
96
96
@@ -169,34 +169,38 @@ bool ParamPackMatcher::match() {
169
169
170
170
// If the left hand side is a single pack expansion type, bind it
171
171
// 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);
180
181
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
+ }
184
186
}
185
187
186
188
// If the right hand side is a single pack expansion type, bind it
187
189
// 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);
196
199
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
+ }
200
204
}
201
205
202
206
// Otherwise, all remaining possibilities are invalid:
0 commit comments