@@ -1548,17 +1548,19 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
1548
1548
def typedAsFunction (tree : untpd.PostfixOp , pt : Type )(implicit ctx : Context ): Tree = {
1549
1549
val untpd .PostfixOp (qual, Ident (nme.WILDCARD )) = tree
1550
1550
val pt1 = if (defn.isFunctionType(pt)) pt else AnyFunctionProto
1551
- var res = typed(qual, pt1)
1552
- if (pt1.eq(AnyFunctionProto ) && ! defn.isFunctionClass(res.tpe.classSymbol)) {
1551
+ val nestedCtx = ctx.fresh.setNewTyperState()
1552
+ var res = typed(qual, pt1)(nestedCtx)
1553
+ if (! defn.isFunctionClass(res.tpe.classSymbol)) {
1553
1554
ctx.errorOrMigrationWarning(OnlyFunctionsCanBeFollowedByUnderscore (res.tpe), tree.pos)
1554
1555
if (ctx.scala2Mode) {
1555
1556
// Under -rewrite, patch `x _` to `(() => x)`
1556
1557
patch(Position (tree.pos.start), " (() => " )
1557
1558
patch(Position (qual.pos.end, tree.pos.end), " )" )
1558
- res = typed(untpd.Function (Nil , untpd. TypedSplice ( res) ))
1559
+ return typed(untpd.Function (Nil , res))
1559
1560
}
1560
1561
}
1561
- else if (ctx.settings.strict.value) {
1562
+ nestedCtx.typerState.commit()
1563
+ if (ctx.settings.strict.value) {
1562
1564
lazy val (prefix, suffix) = res match {
1563
1565
case Block (mdef @ DefDef (_, _, vparams :: Nil , _, _) :: Nil , _ : Closure ) =>
1564
1566
val arity = vparams.length
0 commit comments