aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/ast/Trees.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2015-02-25 18:29:30 +0100
committerDmitry Petrashko <dmitry.petrashko@gmail.com>2015-03-18 11:14:10 +0100
commit1b301e9b8da1fc48b1720cccedafdb7cdb7058a4 (patch)
treeadfdf48087277745254595c113a620dbdc4e5641 /src/dotty/tools/dotc/ast/Trees.scala
parentafeb331346d49e8fd0b47178365b3f95bf89b340 (diff)
downloaddotty-1b301e9b8da1fc48b1720cccedafdb7cdb7058a4.tar.gz
dotty-1b301e9b8da1fc48b1720cccedafdb7cdb7058a4.tar.bz2
dotty-1b301e9b8da1fc48b1720cccedafdb7cdb7058a4.zip
New scheme for recording positions
Single traverser, also handles lazy trees.
Diffstat (limited to 'src/dotty/tools/dotc/ast/Trees.scala')
-rw-r--r--src/dotty/tools/dotc/ast/Trees.scala27
1 files changed, 14 insertions, 13 deletions
diff --git a/src/dotty/tools/dotc/ast/Trees.scala b/src/dotty/tools/dotc/ast/Trees.scala
index 1973a4947..b0dc8a089 100644
--- a/src/dotty/tools/dotc/ast/Trees.scala
+++ b/src/dotty/tools/dotc/ast/Trees.scala
@@ -309,7 +309,7 @@ object Trees {
/** Tree defines a new symbol and carries modifiers.
* The position of a MemberDef contains only the defined identifier or pattern.
- * The envelope of a MemberDef contains the whole definition and his its point
+ * The envelope of a MemberDef contains the whole definition and has its point
* on the opening keyword (or the next token after that if keyword is missing).
*/
abstract class MemberDef[-T >: Untyped] extends NameTree[T] with DefTree[T] {
@@ -330,7 +330,7 @@ object Trees {
protected def setMods(mods: Modifiers[T @uncheckedVariance]) = myMods = mods
- override def envelope: Position = rawMods.pos union pos union initialPos
+ override def envelope: Position = rawMods.pos.union(pos).union(initialPos)
}
/** A ValDef or DefDef tree */
@@ -623,8 +623,8 @@ object Trees {
extends ValOrDefDef[T] {
type ThisTree[-T >: Untyped] = ValDef[T]
assert(isEmpty || tpt != genericEmptyTree)
- protected def maybeLazy = preRhs
- protected def maybeLazy_=(x: Any) = preRhs = x
+ def unforced = preRhs
+ protected def force(x: Any) = preRhs = x
}
/** mods def name[tparams](vparams_1)...(vparams_n): tpt = rhs */
@@ -633,8 +633,9 @@ object Trees {
extends ValOrDefDef[T] {
type ThisTree[-T >: Untyped] = DefDef[T]
assert(tpt != genericEmptyTree)
- protected def maybeLazy = preRhs
- protected def maybeLazy_=(x: Any) = preRhs = x
+ def unforcedRhs = preRhs
+ def unforced = preRhs
+ protected def force(x: Any) = preRhs = x
}
/** mods class name template or
@@ -660,8 +661,8 @@ object Trees {
case class Template[-T >: Untyped] private[ast] (constr: DefDef[T], parents: List[Tree[T]], self: ValDef[T], private var preBody: Any /*List[Tree[T]] | Lazy[List[Tree]]]*/)
extends DefTree[T] with WithLazyField[List[Tree[T]]] {
type ThisTree[-T >: Untyped] = Template[T]
- protected def maybeLazy = preBody
- protected def maybeLazy_=(x: Any) = preBody = x
+ def unforced = preBody
+ protected def force(x: Any) = preBody = x
def body: List[Tree[T]] = forceIfLazy
}
@@ -758,16 +759,16 @@ object Trees {
/** A tree that can have a lazy field
* The field is represented by some private `var` which is
- * proxied by the `maybeLazy` accessors. Forcing the field will
+ * proxied `unforced` and `force`. Forcing the field will
* set the `var` to the underlying value.
*/
trait WithLazyField[+T] {
- protected def maybeLazy: Any
- protected def maybeLazy_=(x: Any): Unit
- def forceIfLazy: T = maybeLazy match {
+ def unforced: Any
+ protected def force(x: Any): Unit
+ def forceIfLazy: T = unforced match {
case lzy: Lazy[T] =>
val x = lzy.complete
- maybeLazy = x
+ force(x)
x
case x: T @ unchecked => x
}