aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2012-12-22 18:04:58 +0100
committerMartin Odersky <odersky@gmail.com>2012-12-22 18:04:58 +0100
commit78f0d5a0e0ea477087385277d217d9300c018aa0 (patch)
tree60d4bdeeb58ddb2d5e5f4e4a871fcec60a8a31f7
parent01d8a0d90520ea60ead7b2e97cdb79f0a70d6d08 (diff)
downloaddotty-78f0d5a0e0ea477087385277d217d9300c018aa0.tar.gz
dotty-78f0d5a0e0ea477087385277d217d9300c018aa0.tar.bz2
dotty-78f0d5a0e0ea477087385277d217d9300c018aa0.zip
Changed scheme in Trees so that immutable trees are now Tree[Nothing].
-rw-r--r--src/dotty/tools/dotc/core/Trees.scala26
1 files changed, 11 insertions, 15 deletions
diff --git a/src/dotty/tools/dotc/core/Trees.scala b/src/dotty/tools/dotc/core/Trees.scala
index 26cb0a0cc..df09ab60d 100644
--- a/src/dotty/tools/dotc/core/Trees.scala
+++ b/src/dotty/tools/dotc/core/Trees.scala
@@ -8,15 +8,6 @@ object Trees {
val flags: FlagSet
}
- class MissingType {
- type Type
- }
-
- val missing: MissingType =
- new MissingType {
- type Type = Types.Type
- }
-
/** Trees take a parameter indicating what the type of their `tpe` field
* is. Two choices: `Types.Type` or `missing.Type`.
* Untyped trees have type `Tree[missing.Type]`. Because `missing.Type`
@@ -50,16 +41,15 @@ object Trees {
val tree =
(if (_tpe == null ||
(_tpe.asInstanceOf[AnyRef] eq tpe.asInstanceOf[AnyRef])) this
- else shallowCopy).asInstanceOf[Tree[Type]]
+ else clone).asInstanceOf[Tree[Type]]
tree._tpe = tpe
tree
}
- def shallowCopy: Tree[T] = clone.asInstanceOf[Tree[T]]
-
+ def withPosition(pos: Position) = ???
}
- case class Ident[T](name: Name)(implicit val pos: Position) extends Tree[T]
+ case class Ident[T] (name: Name)(implicit val pos: Position) extends Tree[T]
case class Select[T](qualifier: Tree[T], name: Name)(implicit val pos: Position) extends Tree[T]
@@ -73,11 +63,17 @@ object Trees {
case class DefDef[T](mods: Modifiers, name: Name, tparams: List[TypeDef[T]], vparamss: List[List[ValDef[T]]], rtpe: Tree[T], rhs: Tree[T])(implicit val pos: Position) extends Tree[T]
- case class TypedSplice(tree: Tree[Type]) extends Tree[missing.Type] {
+ class ImplicitDefDef[T](mods: Modifiers, name: Name, tparams: List[TypeDef[T]], vparamss: List[List[ValDef[T]]], rtpe: Tree[T], rhs: Tree[T])
+ (implicit pos: Position) extends DefDef[T](mods, name, tparams, vparamss, rtpe, rhs) {
+ override def copy[T](mods: Modifiers, name: Name, tparams: List[TypeDef[T]], vparamss: List[List[ValDef[T]]], rtpe: Tree[T], rhs: Tree[T])(implicit pos: Position) =
+ new ImplicitDefDef[T](mods, name, tparams, vparamss, rtpe, rhs)
+ }
+
+ case class TypedSplice(tree: Tree[Type]) extends Tree[Nothing] {
def pos = tree.pos
}
- implicit def embedTyped(tree: Tree[Type]): Tree[missing.Type] = TypedSplice(tree)
+ implicit def embedTyped(tree: Tree[Type]): Tree[Nothing] = TypedSplice(tree)
class UnAssignedTypeException[T](tree: Tree[T]) extends Exception {
override def getMessage: String = s"type of $tree is not assigned"