@@ -1548,17 +1548,19 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
15481548 def typedAsFunction (tree : untpd.PostfixOp , pt : Type )(implicit ctx : Context ): Tree = {
15491549 val untpd .PostfixOp (qual, Ident (nme.WILDCARD )) = tree
15501550 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)) {
15531554 ctx.errorOrMigrationWarning(OnlyFunctionsCanBeFollowedByUnderscore (res.tpe), tree.pos)
15541555 if (ctx.scala2Mode) {
15551556 // Under -rewrite, patch `x _` to `(() => x)`
15561557 patch(Position (tree.pos.start), " (() => " )
15571558 patch(Position (qual.pos.end, tree.pos.end), " )" )
1558- res = typed(untpd.Function (Nil , untpd. TypedSplice ( res) ))
1559+ return typed(untpd.Function (Nil , res))
15591560 }
15601561 }
1561- else if (ctx.settings.strict.value) {
1562+ nestedCtx.typerState.commit()
1563+ if (ctx.settings.strict.value) {
15621564 lazy val (prefix, suffix) = res match {
15631565 case Block (mdef @ DefDef (_, _, vparams :: Nil , _, _) :: Nil , _ : Closure ) =>
15641566 val arity = vparams.length
0 commit comments