@@ -1549,15 +1549,17 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
15491549 val untpd .PostfixOp (qual, Ident (nme.WILDCARD )) = tree
15501550 val pt1 = if (defn.isFunctionType(pt)) pt else AnyFunctionProto
15511551 val nestedCtx = ctx.fresh.setNewTyperState()
1552- var res = typed(qual, pt1)(nestedCtx)
1553- if (! defn.isFunctionClass(res.tpe.classSymbol)) {
1554- ctx.errorOrMigrationWarning(OnlyFunctionsCanBeFollowedByUnderscore (res.tpe), tree.pos)
1555- if (ctx.scala2Mode) {
1556- // Under -rewrite, patch `x _` to `(() => x)`
1557- patch(Position (tree.pos.start), " (() => " )
1558- patch(Position (qual.pos.end, tree.pos.end), " )" )
1559- return typed(untpd.Function (Nil , res))
1560- }
1552+ val res = typed(qual, pt1)(nestedCtx)
1553+ res match {
1554+ case res @ closure(_, _, _) =>
1555+ case _ =>
1556+ ctx.errorOrMigrationWarning(OnlyFunctionsCanBeFollowedByUnderscore (res.tpe), tree.pos)
1557+ if (ctx.scala2Mode) {
1558+ // Under -rewrite, patch `x _` to `(() => x)`
1559+ patch(Position (tree.pos.start), " (() => " )
1560+ patch(Position (qual.pos.end, tree.pos.end), " )" )
1561+ return typed(untpd.Function (Nil , qual), pt)
1562+ }
15611563 }
15621564 nestedCtx.typerState.commit()
15631565 if (ctx.settings.strict.value) {
0 commit comments