@@ -33,6 +33,7 @@ import annotation.tailrec
33
33
import Implicits ._
34
34
import util .Stats .{track , record }
35
35
import config .Printers ._
36
+ import rewrite .Rewrites .patch
36
37
import language .implicitConversions
37
38
38
39
object Typer {
@@ -1134,13 +1135,15 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
1134
1135
}
1135
1136
}
1136
1137
1137
- def typedAsFunction (tree : untpd.Tree , pt : Type )(implicit ctx : Context ): Tree = {
1138
+ def typedAsFunction (tree : untpd.PostfixOp , pt : Type )(implicit ctx : Context ): Tree = {
1139
+ val untpd .PostfixOp (qual, nme.WILDCARD ) = tree
1138
1140
val pt1 = if (defn.isFunctionType(pt)) pt else AnyFunctionProto
1139
- var res = typed(tree , pt1)
1141
+ var res = typed(qual , pt1)
1140
1142
if (pt1.eq(AnyFunctionProto ) && ! defn.isFunctionClass(res.tpe.classSymbol)) {
1141
1143
def msg = i " not a function: ${res.tpe}; cannot be followed by `_' "
1142
1144
if (ctx.scala2Mode) {
1143
1145
ctx.migrationWarning(msg, tree.pos)
1146
+ patch(ctx.compilationUnit.source, Position (qual.pos.end, tree.pos.end), " " )
1144
1147
res = typed(untpd.Function (Nil , untpd.TypedSplice (res)))
1145
1148
}
1146
1149
else ctx.error(msg, tree.pos)
@@ -1231,7 +1234,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
1231
1234
case tree : untpd.Annotated => typedAnnotated(tree, pt)
1232
1235
case tree : untpd.TypedSplice => tree.tree
1233
1236
case tree : untpd.UnApply => typedUnApply(tree, pt)
1234
- case untpd.PostfixOp (tree , nme.WILDCARD ) => typedAsFunction(tree, pt)
1237
+ case tree @ untpd.PostfixOp (qual , nme.WILDCARD ) => typedAsFunction(tree, pt)
1235
1238
case untpd.EmptyTree => tpd.EmptyTree
1236
1239
case _ => typedUnadapted(desugar(tree), pt)
1237
1240
}
0 commit comments