aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/dotty/tools/dotc/typer
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2017-03-28 22:25:09 +0200
committerMartin Odersky <odersky@gmail.com>2017-04-11 09:33:11 +0200
commitca5652cc5a74f00277ce942a001fa6e931ee3728 (patch)
tree9ef6e2b341bc10678bbe1f06d4c15fb28093da07 /compiler/src/dotty/tools/dotc/typer
parent1e49ddad97c4e8207913857511ae62467f8cd3ce (diff)
downloaddotty-ca5652cc5a74f00277ce942a001fa6e931ee3728.tar.gz
dotty-ca5652cc5a74f00277ce942a001fa6e931ee3728.tar.bz2
dotty-ca5652cc5a74f00277ce942a001fa6e931ee3728.zip
Make freshName semantic
Diffstat (limited to 'compiler/src/dotty/tools/dotc/typer')
-rw-r--r--compiler/src/dotty/tools/dotc/typer/EtaExpansion.scala9
-rw-r--r--compiler/src/dotty/tools/dotc/typer/Inliner.scala4
-rw-r--r--compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala3
3 files changed, 9 insertions, 7 deletions
diff --git a/compiler/src/dotty/tools/dotc/typer/EtaExpansion.scala b/compiler/src/dotty/tools/dotc/typer/EtaExpansion.scala
index 5aee0fd54..3f3a0cce3 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 NameExtractors.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 contains '$') EmptyTermName else name)
}
case _ =>
args map (liftArg(defs, _))
diff --git a/compiler/src/dotty/tools/dotc/typer/Inliner.scala b/compiler/src/dotty/tools/dotc/typer/Inliner.scala
index f6d65fbb9..ad65af98c 100644
--- a/compiler/src/dotty/tools/dotc/typer/Inliner.scala
+++ b/compiler/src/dotty/tools/dotc/typer/Inliner.scala
@@ -15,6 +15,7 @@ import StdNames.nme
import Contexts.Context
import Names.{Name, TermName}
import NameOps._
+import NameExtractors.InlineAccessorName
import SymDenotations.SymDenotation
import Annotations._
import transform.ExplicitOuter
@@ -49,8 +50,7 @@ object Inliner {
sym.is(AccessFlags) || sym.privateWithin.exists
/** The name of the next accessor to be generated */
- def accessorName(implicit ctx: Context) =
- ctx.freshNames.newName(inlineMethod.name.asTermName.inlineAccessorName.toString)
+ def accessorName(implicit ctx: Context) = InlineAccessorName.fresh(inlineMethod.name.asTermName)
/** A fresh accessor symbol.
*
diff --git a/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala b/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala
index ab342dc17..03357fee3 100644
--- a/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala
+++ b/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala
@@ -5,6 +5,7 @@ package typer
import core._
import ast._
import Contexts._, Types._, Flags._, Denotations._, Names._, StdNames._, NameOps._, Symbols._
+import NameExtractors.DepParamName
import Trees._
import Constants._
import Scopes._
@@ -401,7 +402,7 @@ object ProtoTypes {
/** Create a new TypeParamRef that represents a dependent method parameter singleton */
def newDepTypeParamRef(tp: Type)(implicit ctx: Context): TypeParamRef = {
- val poly = PolyType(ctx.freshName(nme.DEP_PARAM_PREFIX).toTypeName :: Nil)(
+ val poly = PolyType(DepParamName.fresh().toTypeName :: Nil)(
pt => TypeBounds.upper(AndType(tp, defn.SingletonType)) :: Nil,
pt => defn.AnyType)
ctx.typeComparer.addToConstraint(poly, Nil)