@@ -1439,6 +1439,20 @@ trait Applications extends Compatibility {
1439
1439
else (unapplyFn, unapplyAppCall)
1440
1440
end inlinedUnapplyFnAndApp
1441
1441
1442
+ def unapplyImplicits (dummyArg : Tree , unapp : Tree ): List [Tree ] =
1443
+ val res = List .newBuilder[Tree ]
1444
+ def loop (unapp : Tree ): Unit = unapp match
1445
+ case Apply (Apply (unapply, `dummyArg` :: Nil ), args2) => assert(args2.nonEmpty); res ++= args2
1446
+ case Apply (unapply, `dummyArg` :: Nil ) =>
1447
+ case Inlined (u, _, _) => loop(u)
1448
+ case DynamicUnapply (_) => report.error(em " Structural unapply is not supported " , unapplyFn.srcPos)
1449
+ case Apply (fn, args) => assert(args.nonEmpty); loop(fn); res ++= args
1450
+ case _ => ().assertingErrorsReported
1451
+
1452
+ loop(unapp)
1453
+ res.result()
1454
+ end unapplyImplicits
1455
+
1442
1456
/** Add a `Bind` node for each `bound` symbol in a type application `unapp` */
1443
1457
def addBinders (unapp : Tree , bound : List [Symbol ]) = unapp match {
1444
1458
case TypeApply (fn, args) =>
@@ -1482,20 +1496,6 @@ trait Applications extends Compatibility {
1482
1496
typedExpr(untpd.TypedSplice (Apply (unapplyFn, dummyArg :: Nil )))
1483
1497
inlinedUnapplyFnAndApp(dummyArg, unapplyAppCall)
1484
1498
1485
- def unapplyImplicits (unapp : Tree ): List [Tree ] = {
1486
- val res = List .newBuilder[Tree ]
1487
- def loop (unapp : Tree ): Unit = unapp match {
1488
- case Apply (Apply (unapply, `dummyArg` :: Nil ), args2) => assert(args2.nonEmpty); res ++= args2
1489
- case Apply (unapply, `dummyArg` :: Nil ) =>
1490
- case Inlined (u, _, _) => loop(u)
1491
- case DynamicUnapply (_) => report.error(em " Structural unapply is not supported " , unapplyFn.srcPos)
1492
- case Apply (fn, args) => assert(args.nonEmpty); loop(fn); res ++= args
1493
- case _ => ().assertingErrorsReported
1494
- }
1495
- loop(unapp)
1496
- res.result()
1497
- }
1498
-
1499
1499
var argTypes = unapplyArgs(unapplyApp.tpe, unapplyFn, args, tree.srcPos)
1500
1500
for (argType <- argTypes) assert(! isBounds(argType), unapplyApp.tpe.show)
1501
1501
val bunchedArgs = argTypes match {
@@ -1510,7 +1510,7 @@ trait Applications extends Compatibility {
1510
1510
List .fill(argTypes.length - args.length)(WildcardType )
1511
1511
}
1512
1512
val unapplyPatterns = bunchedArgs.lazyZip(argTypes) map (typed(_, _))
1513
- val result = assignType(cpy.UnApply (tree)(newUnapplyFn, unapplyImplicits(unapplyApp), unapplyPatterns), ownType)
1513
+ val result = assignType(cpy.UnApply (tree)(newUnapplyFn, unapplyImplicits(dummyArg, unapplyApp), unapplyPatterns), ownType)
1514
1514
unapp.println(s " unapply patterns = $unapplyPatterns" )
1515
1515
if (ownType.stripped eq selType.stripped) || ownType.isError then result
1516
1516
else tryWithTypeTest(Typed (result, TypeTree (ownType)), selType)
0 commit comments