summaryrefslogtreecommitdiff
path: root/src/library/scala/reflect/api/Trees.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2012-03-15 09:28:07 -0700
committerPaul Phillips <paulp@improving.org>2012-03-15 19:59:46 -0700
commitacb2c851720141982514b11b4b34ba68dc868bf2 (patch)
treec6aa85586f6f673e5975266314cc613a7d36ed05 /src/library/scala/reflect/api/Trees.scala
parent2dd0af0675ea0c4d696a46bf36d7bd9406a64cd0 (diff)
downloadscala-acb2c851720141982514b11b4b34ba68dc868bf2.tar.gz
scala-acb2c851720141982514b11b4b34ba68dc868bf2.tar.bz2
scala-acb2c851720141982514b11b4b34ba68dc868bf2.zip
New option -Ypos-debug, and fixed range position breakage.
(Looks like there is more range position breakage yet, but this gets the outermost layer.) Channeling my struggles into a slightly easier future. % scalac -Ypos-debug -d /tmp ./src/library/scala/Predef.scala ./src/library/scala/Predef.scala:222: warning: Positioned tree has unpositioned child in phase extmethods def x = __resultOfEnsuring ^ parent: #7109 line 222 Select // (value __resultOfEnsuring in class Ensuring) child: #7108 Ident // (value $this) ./src/library/scala/Predef.scala:258: warning: Positioned tree has unpositioned child in phase extmethods def x = __leftOfArrow ^ parent: #7280 line 258 Select // (value __leftOfArrow in class ArrowAssoc) child: #7279 Ident // (value $this) two warnings found Or try this to really see some output: % scalac -Yrangepos -Ypos-debug
Diffstat (limited to 'src/library/scala/reflect/api/Trees.scala')
-rw-r--r--src/library/scala/reflect/api/Trees.scala18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/library/scala/reflect/api/Trees.scala b/src/library/scala/reflect/api/Trees.scala
index 181ce85dac..a355207ff0 100644
--- a/src/library/scala/reflect/api/Trees.scala
+++ b/src/library/scala/reflect/api/Trees.scala
@@ -309,7 +309,7 @@ trait Trees { self: Universe =>
* quite frequently called modules to reduce ambiguity.
*/
case class ModuleDef(mods: Modifiers, name: TermName, impl: Template)
- extends ImplDef
+ extends ImplDef
/** A common base class for ValDefs and DefDefs.
*/
@@ -319,8 +319,13 @@ trait Trees { self: Universe =>
def rhs: Tree
}
- /** A value definition (this includes vars as well, which differ from
- * vals only in having the MUTABLE flag set in their Modifiers.)
+ /** Broadly speaking, a value definition. All these are encoded as ValDefs:
+ *
+ * - immutable values, e.g. "val x"
+ * - mutable values, e.g. "var x" - the MUTABLE flag set in mods
+ * - lazy values, e.g. "lazy val x" - the LAZY flag set in mods
+ * - method parameters, see vparamss in DefDef - the PARAM flag is set in mods
+ * - explicit self-types, e.g. class A { self: Bar => } - !!! not sure what is set.
*/
case class ValDef(mods: Modifiers, name: TermName, tpt: Tree, rhs: Tree) extends ValOrDefDef
@@ -390,7 +395,6 @@ trait Trees { self: Universe =>
// {
// def bar // owner is local dummy
// }
- // System.err.println("TEMPLATE: " + parents)
}
/** Block of expressions (semicolon separated expressions) */
@@ -741,6 +745,12 @@ trait Trees { self: Universe =>
case t =>
sys.error("Not a ClassDef: " + t + "/" + t.getClass)
}
+ def deriveModuleDef(mdef: Tree)(applyToImpl: Template => Template): ModuleDef = mdef match {
+ case ModuleDef(mods0, name0, impl0) =>
+ treeCopy.ModuleDef(mdef, mods0, name0, applyToImpl(impl0))
+ case t =>
+ sys.error("Not a ModuleDef: " + t + "/" + t.getClass)
+ }
def deriveCaseDef(cdef: Tree)(applyToBody: Tree => Tree): CaseDef = cdef match {
case CaseDef(pat0, guard0, body0) =>
treeCopy.CaseDef(cdef, pat0, guard0, applyToBody(body0))