@@ -1423,6 +1423,20 @@ trait Applications extends Compatibility {
1423
1423
else (unapplyFn, unapplyAppCall)
1424
1424
end inlinedUnapplyFnAndApp
1425
1425
1426
+ def unapplyImplicits (dummyArg : Tree , unapp : Tree ): List [Tree ] =
1427
+ val res = List .newBuilder[Tree ]
1428
+ def loop (unapp : Tree ): Unit = unapp match
1429
+ case Apply (Apply (unapply, `dummyArg` :: Nil ), args2) => assert(args2.nonEmpty); res ++= args2
1430
+ case Apply (unapply, `dummyArg` :: Nil ) =>
1431
+ case Inlined (u, _, _) => loop(u)
1432
+ case DynamicUnapply (_) => report.error(em " Structural unapply is not supported " , unapplyFn.srcPos)
1433
+ case Apply (fn, args) => assert(args.nonEmpty); loop(fn); res ++= args
1434
+ case _ => ().assertingErrorsReported
1435
+
1436
+ loop(unapp)
1437
+ res.result()
1438
+ end unapplyImplicits
1439
+
1426
1440
/** Add a `Bind` node for each `bound` symbol in a type application `unapp` */
1427
1441
def addBinders (unapp : Tree , bound : List [Symbol ]) = unapp match {
1428
1442
case TypeApply (fn, args) =>
@@ -1466,20 +1480,6 @@ trait Applications extends Compatibility {
1466
1480
typedExpr(untpd.TypedSplice (Apply (unapplyFn, dummyArg :: Nil )))
1467
1481
inlinedUnapplyFnAndApp(dummyArg, unapplyAppCall)
1468
1482
1469
- def unapplyImplicits (unapp : Tree ): List [Tree ] = {
1470
- val res = List .newBuilder[Tree ]
1471
- def loop (unapp : Tree ): Unit = unapp match {
1472
- case Apply (Apply (unapply, `dummyArg` :: Nil ), args2) => assert(args2.nonEmpty); res ++= args2
1473
- case Apply (unapply, `dummyArg` :: Nil ) =>
1474
- case Inlined (u, _, _) => loop(u)
1475
- case DynamicUnapply (_) => report.error(em " Structural unapply is not supported " , unapplyFn.srcPos)
1476
- case Apply (fn, args) => assert(args.nonEmpty); loop(fn); res ++= args
1477
- case _ => ().assertingErrorsReported
1478
- }
1479
- loop(unapp)
1480
- res.result()
1481
- }
1482
-
1483
1483
var argTypes = unapplyArgs(unapplyApp.tpe, unapplyFn, args, tree.srcPos)
1484
1484
for (argType <- argTypes) assert(! isBounds(argType), unapplyApp.tpe.show)
1485
1485
val bunchedArgs = argTypes match {
@@ -1494,7 +1494,7 @@ trait Applications extends Compatibility {
1494
1494
List .fill(argTypes.length - args.length)(WildcardType )
1495
1495
}
1496
1496
val unapplyPatterns = bunchedArgs.lazyZip(argTypes) map (typed(_, _))
1497
- val result = assignType(cpy.UnApply (tree)(newUnapplyFn, unapplyImplicits(unapplyApp), unapplyPatterns), ownType)
1497
+ val result = assignType(cpy.UnApply (tree)(newUnapplyFn, unapplyImplicits(dummyArg, unapplyApp), unapplyPatterns), ownType)
1498
1498
unapp.println(s " unapply patterns = $unapplyPatterns" )
1499
1499
if (ownType.stripped eq selType.stripped) || ownType.isError then result
1500
1500
else tryWithTypeTest(Typed (result, TypeTree (ownType)), selType)
0 commit comments