aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/dotty/tools/dotc/typer/EtaExpansion.scala
diff options
context:
space:
mode:
authorodersky <odersky@gmail.com>2017-04-11 11:49:40 +0200
committerGitHub <noreply@github.com>2017-04-11 11:49:40 +0200
commit579571e05a08120133173933e7eaf2555846d1d7 (patch)
tree7b0c89291126e89a901a8ab1230f874e26e25515 /compiler/src/dotty/tools/dotc/typer/EtaExpansion.scala
parent4ff656138a2e4e127b763adeee3f0f72d515f6b6 (diff)
parent87608bded1fb23519a829fa7f6ee14d4b6a515dc (diff)
downloaddotty-579571e05a08120133173933e7eaf2555846d1d7.tar.gz
dotty-579571e05a08120133173933e7eaf2555846d1d7.tar.bz2
dotty-579571e05a08120133173933e7eaf2555846d1d7.zip
Merge pull request #2128 from dotty-staging/add-semantic-names
Delay name mangling
Diffstat (limited to 'compiler/src/dotty/tools/dotc/typer/EtaExpansion.scala')
-rw-r--r--compiler/src/dotty/tools/dotc/typer/EtaExpansion.scala9
1 files changed, 5 insertions, 4 deletions
diff --git a/compiler/src/dotty/tools/dotc/typer/EtaExpansion.scala b/compiler/src/dotty/tools/dotc/typer/EtaExpansion.scala
index 5aee0fd54..e5480c98d 100644
--- a/compiler/src/dotty/tools/dotc/typer/EtaExpansion.scala
+++ b/compiler/src/dotty/tools/dotc/typer/EtaExpansion.scala
@@ -12,6 +12,7 @@ import Symbols._
import Decorators._
import Names._
import StdNames._
+import NameKinds.UniqueName
import Trees._
import Inferencing._
import util.Positions._
@@ -21,10 +22,10 @@ object EtaExpansion {
import tpd._
- private def lift(defs: mutable.ListBuffer[Tree], expr: Tree, prefix: String = "")(implicit ctx: Context): Tree =
+ private def lift(defs: mutable.ListBuffer[Tree], expr: Tree, prefix: TermName = EmptyTermName)(implicit ctx: Context): Tree =
if (isPureExpr(expr)) expr
else {
- val name = ctx.freshName(prefix).toTermName
+ val name = UniqueName.fresh(prefix)
val liftedType = fullyDefinedType(expr.tpe.widen, "lifted expression", expr.pos)
val sym = ctx.newSymbol(ctx.owner, name, EmptyFlags, liftedType, coord = positionCoord(expr.pos))
defs += ValDef(sym, expr)
@@ -48,7 +49,7 @@ object EtaExpansion {
}
/** Lift a function argument, stripping any NamedArg wrapper */
- def liftArg(defs: mutable.ListBuffer[Tree], arg: Tree, prefix: String = "")(implicit ctx: Context): Tree =
+ def liftArg(defs: mutable.ListBuffer[Tree], arg: Tree, prefix: TermName = EmptyTermName)(implicit ctx: Context): Tree =
arg match {
case arg @ NamedArg(name, arg1) => cpy.NamedArg(arg)(name, lift(defs, arg1, prefix))
case arg => lift(defs, arg, prefix)
@@ -62,7 +63,7 @@ object EtaExpansion {
case mt: MethodType =>
(args, mt.paramNames, mt.paramInfos).zipped map { (arg, name, tp) =>
if (tp.isInstanceOf[ExprType]) arg
- else liftArg(defs, arg, if (name contains '$') "" else name.toString + "$")
+ else liftArg(defs, arg, if (name.firstPart contains '$') EmptyTermName else name)
}
case _ =>
args map (liftArg(defs, _))