aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/ast/Trees.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2016-11-11 22:20:24 +0100
committerMartin Odersky <odersky@gmail.com>2016-11-11 22:20:24 +0100
commit97b6985c34915b58e0c81fbab464f4bd532c27d0 (patch)
tree968795a36f2eb50791166f8288a8d5ad1f72c285 /src/dotty/tools/dotc/ast/Trees.scala
parentf3c8fdddcc7a5aef1c206afb0942d4a961ef1186 (diff)
downloaddotty-97b6985c34915b58e0c81fbab464f4bd532c27d0.tar.gz
dotty-97b6985c34915b58e0c81fbab464f4bd532c27d0.tar.bz2
dotty-97b6985c34915b58e0c81fbab464f4bd532c27d0.zip
Clean up parameterized typedefs
Express them in terms PolyTypeTrees rather than having an irregular, untyped only tparams field. This is necessary if we want to pickle type trees instead of types, because now the rhs of a typedef tells the whole story, so we are not required any longer to use the info of the symbol.
Diffstat (limited to 'src/dotty/tools/dotc/ast/Trees.scala')
-rw-r--r--src/dotty/tools/dotc/ast/Trees.scala27
1 files changed, 10 insertions, 17 deletions
diff --git a/src/dotty/tools/dotc/ast/Trees.scala b/src/dotty/tools/dotc/ast/Trees.scala
index 9108a4d22..78ac66812 100644
--- a/src/dotty/tools/dotc/ast/Trees.scala
+++ b/src/dotty/tools/dotc/ast/Trees.scala
@@ -60,18 +60,18 @@ object Trees {
with Cloneable {
if (Stats.enabled) ntrees += 1
-
+
private def nxId = {
nextId += 1
//assert(nextId != 199, this)
- nextId
+ nextId
}
/** A unique identifier for this tree. Used for debugging, and potentially
* tracking presentation compiler interactions
*/
private var myUniqueId: Int = nxId
-
+
def uniqueId = myUniqueId
/** The type constructor at the root of the tree */
@@ -192,7 +192,7 @@ object Trees {
override def hashCode(): Int = uniqueId // for debugging; was: System.identityHashCode(this)
override def equals(that: Any) = this eq that.asInstanceOf[AnyRef]
-
+
override def clone: Tree[T] = {
val tree = super.clone.asInstanceOf[Tree[T]]
tree.myUniqueId = nxId
@@ -653,12 +653,6 @@ object Trees {
/** Is this a definition of a class? */
def isClassDef = rhs.isInstanceOf[Template[_]]
-
- /** If this a non-class type definition, its type parameters.
- * Can be different from Nil only for PolyTypeDefs, which are always
- * untyped and get eliminated during desugaring.
- */
- def tparams: List[untpd.TypeDef] = Nil
}
/** extends parents { self => body } */
@@ -1023,9 +1017,9 @@ object Trees {
case tree: DefDef if (name == tree.name) && (tparams eq tree.tparams) && (vparamss eq tree.vparamss) && (tpt eq tree.tpt) && (rhs eq tree.unforcedRhs) => tree
case _ => finalize(tree, untpd.DefDef(name, tparams, vparamss, tpt, rhs))
}
- def TypeDef(tree: Tree)(name: TypeName, rhs: Tree, tparams: List[untpd.TypeDef]): TypeDef = tree match {
- case tree: TypeDef if (name == tree.name) && (rhs eq tree.rhs) && (tparams eq tree.tparams) => tree
- case _ => finalize(tree, untpd.TypeDef(name, tparams, rhs))
+ def TypeDef(tree: Tree)(name: TypeName, rhs: Tree): TypeDef = tree match {
+ case tree: TypeDef if (name == tree.name) && (rhs eq tree.rhs) => tree
+ case _ => finalize(tree, untpd.TypeDef(name, rhs))
}
def Template(tree: Tree)(constr: DefDef, parents: List[Tree], self: ValDef, body: LazyTreeList): Template = tree match {
case tree: Template if (constr eq tree.constr) && (parents eq tree.parents) && (self eq tree.self) && (body eq tree.unforcedBody) => tree
@@ -1064,8 +1058,8 @@ object Trees {
ValDef(tree: Tree)(name, tpt, rhs)
def DefDef(tree: DefDef)(name: TermName = tree.name, tparams: List[TypeDef] = tree.tparams, vparamss: List[List[ValDef]] = tree.vparamss, tpt: Tree = tree.tpt, rhs: LazyTree = tree.unforcedRhs): DefDef =
DefDef(tree: Tree)(name, tparams, vparamss, tpt, rhs)
- def TypeDef(tree: TypeDef)(name: TypeName = tree.name, rhs: Tree = tree.rhs, tparams: List[untpd.TypeDef] = tree.tparams): TypeDef =
- TypeDef(tree: Tree)(name, rhs, tparams)
+ def TypeDef(tree: TypeDef)(name: TypeName = tree.name, rhs: Tree = tree.rhs): TypeDef =
+ TypeDef(tree: Tree)(name, rhs)
def Template(tree: Template)(constr: DefDef = tree.constr, parents: List[Tree] = tree.parents, self: ValDef = tree.self, body: LazyTreeList = tree.unforcedBody): Template =
Template(tree: Tree)(constr, parents, self, body)
}
@@ -1146,7 +1140,7 @@ object Trees {
case tree @ DefDef(name, tparams, vparamss, tpt, _) =>
cpy.DefDef(tree)(name, transformSub(tparams), vparamss mapConserve (transformSub(_)), transform(tpt), transform(tree.rhs))
case tree @ TypeDef(name, rhs) =>
- cpy.TypeDef(tree)(name, transform(rhs), tree.tparams)
+ cpy.TypeDef(tree)(name, transform(rhs))
case tree @ Template(constr, parents, self, _) =>
cpy.Template(tree)(transformSub(constr), transform(parents), transformSub(self), transformStats(tree.body))
case Import(expr, selectors) =>
@@ -1294,7 +1288,6 @@ object Trees {
case tree: Bind => cpy.Bind(tree)(newName, tree.body)
case tree: ValDef => cpy.ValDef(tree)(name = newName.asTermName)
case tree: DefDef => cpy.DefDef(tree)(name = newName.asTermName)
- case tree: untpd.PolyTypeDef => untpd.cpy.PolyTypeDef(tree)(newName.asTypeName, tree.tparams, tree.rhs).withMods(tree.rawMods)
case tree: TypeDef => cpy.TypeDef(tree)(name = newName.asTypeName)
}
}.asInstanceOf[tree.ThisTree[T]]