@@ -328,11 +328,11 @@ object PatternMatcher {
328
328
def isSyntheticScala2Unapply (sym : Symbol ) =
329
329
sym.isAllOf(SyntheticCase ) && sym.owner.is(Scala2x )
330
330
331
- def tupleApp (i : Int , receiver : Tree ) = // manually inlining the call to NonEmptyTuple#apply, because it's an inline method
331
+ def tupleApp (tuple : Type , i : Int , receiver : Tree ) = // manually inlining the call to NonEmptyTuple#apply, because it's an inline method
332
332
ref(defn.RuntimeTuplesModule )
333
333
.select(defn.RuntimeTuples_apply )
334
334
.appliedTo(receiver, Literal (Constant (i)))
335
- .cast(scrutinee.info.memberInfo(caseAccessors(i)).widen )
335
+ .cast(indexTupleType(tuple, i).ensuring(_ != NoType , i " Failed to find type at index $i in $tuple " ) )
336
336
337
337
if (isSyntheticScala2Unapply(unapp.symbol) && caseAccessors.length == args.length)
338
338
def tupleSel (sym : Symbol ) = ref(scrutinee).select(sym)
@@ -342,7 +342,7 @@ object PatternMatcher {
342
342
case tp => tp
343
343
! defn.isTupleNType(tp)
344
344
}
345
- val components = if isGenericTuple then caseAccessors.indices.toList.map(tupleApp(_, ref(scrutinee))) else caseAccessors.map(tupleSel)
345
+ val components = if isGenericTuple then caseAccessors.indices.toList.map(tupleApp(unapp.tpe.finalResultType, _, ref(scrutinee))) else caseAccessors.map(tupleSel)
346
346
matchArgsPlan(components, args, onSuccess)
347
347
else if (unapp.tpe <:< (defn.BooleanType ))
348
348
TestPlan (GuardTest , unapp, unapp.span, onSuccess)
@@ -362,7 +362,7 @@ object PatternMatcher {
362
362
unapplySeqPlan(unappResult, args)
363
363
}
364
364
else if unappResult.info <:< defn.NonEmptyTupleTypeRef then
365
- val components = (0 until foldApplyTupleType(unappResult.denot.info).length).toList.map(tupleApp(_, ref(unappResult)))
365
+ val components = (0 until foldApplyTupleType(unappResult.denot.info).length).toList.map(tupleApp(unappResult.info, _, ref(unappResult)))
366
366
matchArgsPlan(components, args, onSuccess)
367
367
else {
368
368
assert(isGetMatch(unapp.tpe))
0 commit comments