@@ -1418,20 +1418,8 @@ object desugar {
1418
1418
}
1419
1419
}
1420
1420
1421
- // begin desugar
1422
-
1423
- // Special case for `Parens` desugaring: unlike all the desugarings below,
1424
- // its output is not a new tree but an existing one whose position should
1425
- // be preserved, so we shouldn't call `withPos` on it.
1426
- tree match {
1427
- case Parens (t) =>
1428
- return t
1429
- case _ =>
1430
- }
1431
-
1432
- val desugared = tree match {
1433
- case PolyFunction (targs, body) =>
1434
- val Function (vargs, res) = body
1421
+ def makePolyFunction (targs : List [Tree ], body : Tree ): Tree = body match {
1422
+ case Function (vargs, res) =>
1435
1423
// TODO: Figure out if we need a `PolyFunctionWithMods` instead.
1436
1424
val mods = body match {
1437
1425
case body : FunctionWithMods => body.mods
@@ -1455,10 +1443,28 @@ object desugar {
1455
1443
1456
1444
val applyVParams = vargs.asInstanceOf [List [ValDef ]]
1457
1445
.map(varg => varg.withAddedFlags(mods.flags | Param ))
1458
- New (Template (emptyConstructor, List (polyFunctionTpt), Nil , EmptyValDef ,
1459
- List (DefDef (nme.apply, applyTParams, List (applyVParams), TypeTree (), res))
1460
- ))
1446
+ New (Template (emptyConstructor, List (polyFunctionTpt), Nil , EmptyValDef ,
1447
+ List (DefDef (nme.apply, applyTParams, List (applyVParams), TypeTree (), res))
1448
+ ))
1461
1449
}
1450
+ case _ =>
1451
+ EmptyTree // may happen for erroneous input
1452
+ }
1453
+
1454
+ // begin desugar
1455
+
1456
+ // Special case for `Parens` desugaring: unlike all the desugarings below,
1457
+ // its output is not a new tree but an existing one whose position should
1458
+ // be preserved, so we shouldn't call `withPos` on it.
1459
+ tree match {
1460
+ case Parens (t) =>
1461
+ return t
1462
+ case _ =>
1463
+ }
1464
+
1465
+ val desugared = tree match {
1466
+ case PolyFunction (targs, body) =>
1467
+ makePolyFunction(targs, body) orElse tree
1462
1468
case SymbolLit (str) =>
1463
1469
Literal (Constant (scala.Symbol (str)))
1464
1470
case InterpolatedString (id, segments) =>
0 commit comments