diff options
author | Martin Odersky <odersky@gmail.com> | 2016-03-08 18:07:48 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2016-03-12 16:08:38 +0100 |
commit | 919f268cd93c3ad1c3cb629caa7c11bbb0e8af8f (patch) | |
tree | 4ac9a5ed9ce758df1f18ee82f82c9b375bc432ec /src/dotty/tools/dotc/typer/Typer.scala | |
parent | 4db804bc7b75038a8b4a36d4132af21e30c15ebc (diff) | |
download | dotty-919f268cd93c3ad1c3cb629caa7c11bbb0e8af8f.tar.gz dotty-919f268cd93c3ad1c3cb629caa7c11bbb0e8af8f.tar.bz2 dotty-919f268cd93c3ad1c3cb629caa7c11bbb0e8af8f.zip |
Patch redundant `_' suffixes.
Scala2 allows `x _` even if `x` is not a method.
Dotty disallows them. The patch removes the ` _`
in these cases.
Diffstat (limited to 'src/dotty/tools/dotc/typer/Typer.scala')
-rw-r--r-- | src/dotty/tools/dotc/typer/Typer.scala | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala index fdb92a40b..b9940e367 100644 --- a/src/dotty/tools/dotc/typer/Typer.scala +++ b/src/dotty/tools/dotc/typer/Typer.scala @@ -33,6 +33,7 @@ import annotation.tailrec import Implicits._ import util.Stats.{track, record} import config.Printers._ +import rewrite.Rewrites.patch import language.implicitConversions object Typer { @@ -1135,13 +1136,15 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit } } - def typedAsFunction(tree: untpd.Tree, pt: Type)(implicit ctx: Context): Tree = { + def typedAsFunction(tree: untpd.PostfixOp, pt: Type)(implicit ctx: Context): Tree = { + val untpd.PostfixOp(qual, nme.WILDCARD) = tree val pt1 = if (defn.isFunctionType(pt)) pt else AnyFunctionProto - var res = typed(tree, pt1) + var res = typed(qual, pt1) if (pt1.eq(AnyFunctionProto) && !defn.isFunctionClass(res.tpe.classSymbol)) { def msg = i"not a function: ${res.tpe}; cannot be followed by `_'" if (ctx.scala2Mode) { ctx.migrationWarning(msg, tree.pos) + patch(ctx.compilationUnit.source, Position(qual.pos.end, tree.pos.end), "") res = typed(untpd.Function(Nil, untpd.TypedSplice(res))) } else ctx.error(msg, tree.pos) @@ -1232,7 +1235,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit case tree: untpd.Annotated => typedAnnotated(tree, pt) case tree: untpd.TypedSplice => tree.tree case tree: untpd.UnApply => typedUnApply(tree, pt) - case untpd.PostfixOp(tree, nme.WILDCARD) => typedAsFunction(tree, pt) + case tree @ untpd.PostfixOp(qual, nme.WILDCARD) => typedAsFunction(tree, pt) case untpd.EmptyTree => tpd.EmptyTree case _ => typedUnadapted(desugar(tree), pt) } |