aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2016-12-13 14:56:00 +0100
committerMartin Odersky <odersky@gmail.com>2016-12-17 18:34:27 +0100
commit71b900fde4cb5937c1cbb19da6e3397586e2467c (patch)
treef2c4680a24a0a89ccb7c10f1725a69dc91df983f
parentcc4c3acf7d0aa9a2e612e228c17dc3f3294f0126 (diff)
downloaddotty-71b900fde4cb5937c1cbb19da6e3397586e2467c.tar.gz
dotty-71b900fde4cb5937c1cbb19da6e3397586e2467c.tar.bz2
dotty-71b900fde4cb5937c1cbb19da6e3397586e2467c.zip
Ref copier that works for Idents and Selects
The Ref copier copies Idents and Selects, changing the name of either.
-rw-r--r--compiler/src/dotty/tools/dotc/ast/Trees.scala5
-rw-r--r--compiler/src/dotty/tools/dotc/ast/tpd.scala3
2 files changed, 7 insertions, 1 deletions
diff --git a/compiler/src/dotty/tools/dotc/ast/Trees.scala b/compiler/src/dotty/tools/dotc/ast/Trees.scala
index 20273eb85..5e2fb99bf 100644
--- a/compiler/src/dotty/tools/dotc/ast/Trees.scala
+++ b/compiler/src/dotty/tools/dotc/ast/Trees.scala
@@ -890,6 +890,11 @@ object Trees {
case tree: Select if (qualifier eq tree.qualifier) && (name == tree.name) => tree
case _ => finalize(tree, untpd.Select(qualifier, name))
}
+ /** Copy Ident or Select trees */
+ def Ref(tree: RefTree)(name: Name)(implicit ctx: Context) = tree match {
+ case Ident(_) => Ident(tree)(name)
+ case Select(qual, _) => Select(tree)(qual, name)
+ }
def This(tree: Tree)(qual: untpd.Ident): This = tree match {
case tree: This if qual eq tree.qual => tree
case _ => finalize(tree, untpd.This(qual))
diff --git a/compiler/src/dotty/tools/dotc/ast/tpd.scala b/compiler/src/dotty/tools/dotc/ast/tpd.scala
index cd6b3fcf2..433808e8e 100644
--- a/compiler/src/dotty/tools/dotc/ast/tpd.scala
+++ b/compiler/src/dotty/tools/dotc/ast/tpd.scala
@@ -450,7 +450,8 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
} else foldOver(sym, tree)
}
- override val cpy = new TypedTreeCopier
+ override val cpy: TypedTreeCopier = // Type ascription needed to pick up any new members in TreeCopier (currently there are none)
+ new TypedTreeCopier
class TypedTreeCopier extends TreeCopier {
def postProcess(tree: Tree, copied: untpd.Tree): copied.ThisTree[Type] =