aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/typer
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-09-18 17:30:04 +0200
committerDmitry Petrashko <dmitry.petrashko@gmail.com>2014-10-11 08:24:35 +0200
commit12a624a75d05372002e4308f4b2830847ca88d3e (patch)
treebd7b21e7b2f4bc2260b66cde151c8ae563541c85 /src/dotty/tools/dotc/typer
parent117b643d0c20aebac6363057d4043ac2cbb817fe (diff)
downloaddotty-12a624a75d05372002e4308f4b2830847ca88d3e.tar.gz
dotty-12a624a75d05372002e4308f4b2830847ca88d3e.tar.bz2
dotty-12a624a75d05372002e4308f4b2830847ca88d3e.zip
Replace tree.withName with {tpd|untpd}.rename.tree
Advantage: Can rename typed as well as untyped trees.
Diffstat (limited to 'src/dotty/tools/dotc/typer')
-rw-r--r--src/dotty/tools/dotc/typer/Applications.scala2
-rw-r--r--src/dotty/tools/dotc/typer/Typer.scala5
2 files changed, 4 insertions, 3 deletions
diff --git a/src/dotty/tools/dotc/typer/Applications.scala b/src/dotty/tools/dotc/typer/Applications.scala
index 2ff116f46..77298e610 100644
--- a/src/dotty/tools/dotc/typer/Applications.scala
+++ b/src/dotty/tools/dotc/typer/Applications.scala
@@ -594,7 +594,7 @@ trait Applications extends Compatibility { self: Typer =>
def followTypeAlias(tree: untpd.Tree): untpd.Tree = {
tree match {
case tree: untpd.RefTree =>
- val ttree = typedType(tree.withName(tree.name.toTypeName))
+ val ttree = typedType(untpd.rename(tree, tree.name.toTypeName))
ttree.tpe match {
case alias: TypeRef if alias.info.isAlias =>
companionRef(alias) match {
diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala
index 9066012f0..9c1110dd1 100644
--- a/src/dotty/tools/dotc/typer/Typer.scala
+++ b/src/dotty/tools/dotc/typer/Typer.scala
@@ -390,7 +390,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
case lhsCore: RefTree if setter.exists =>
val setterTypeRaw = pre select (setterName, setter)
val setterType = ensureAccessible(setterTypeRaw, isSuperSelection(lhsCore), tree.pos)
- val lhs2 = lhsCore.withName(setterName).withType(setterType)
+ val lhs2 = untpd.rename(lhsCore, setterName).withType(setterType)
typed(cpy.Apply(tree)(untpd.TypedSplice(lhs2), tree.rhs :: Nil))
case _ =>
reassignmentToVal
@@ -1009,7 +1009,8 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
}
}
- protected def encodeName(tree: untpd.NameTree)(implicit ctx: Context) = tree withName tree.name.encode
+ protected def encodeName(tree: untpd.NameTree)(implicit ctx: Context): untpd.NameTree =
+ untpd.rename(tree, tree.name.encode)
def typed(tree: untpd.Tree, pt: Type = WildcardType)(implicit ctx: Context): Tree = /*>|>*/ ctx.traceIndented (i"typing $tree", typr, show = true) /*<|<*/ {
assertPositioned(tree)