aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/ast
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2016-09-26 08:44:39 +0200
committerMartin Odersky <odersky@gmail.com>2016-09-26 08:44:39 +0200
commit41ff7c286525855e345fc0641481a7cd9ec2ccee (patch)
tree016603fb46de92b66c1061550d185dcf84784e49 /src/dotty/tools/dotc/ast
parentd096f004b5e6ad88ec406b4ca0163a9cdd4fcb17 (diff)
downloaddotty-41ff7c286525855e345fc0641481a7cd9ec2ccee.tar.gz
dotty-41ff7c286525855e345fc0641481a7cd9ec2ccee.tar.bz2
dotty-41ff7c286525855e345fc0641481a7cd9ec2ccee.zip
Drop tpd.modsDeco
Prefer to access directly via symbol.
Diffstat (limited to 'src/dotty/tools/dotc/ast')
-rw-r--r--src/dotty/tools/dotc/ast/TreeInfo.scala27
-rw-r--r--src/dotty/tools/dotc/ast/Trees.scala7
-rw-r--r--src/dotty/tools/dotc/ast/tpd.scala4
-rw-r--r--src/dotty/tools/dotc/ast/untpd.scala17
4 files changed, 18 insertions, 37 deletions
diff --git a/src/dotty/tools/dotc/ast/TreeInfo.scala b/src/dotty/tools/dotc/ast/TreeInfo.scala
index d6df204c1..725838ef6 100644
--- a/src/dotty/tools/dotc/ast/TreeInfo.scala
+++ b/src/dotty/tools/dotc/ast/TreeInfo.scala
@@ -249,17 +249,6 @@ trait TreeInfo[T >: Untyped <: Type] { self: Trees.Instance[T] =>
/** Is this case guarded? */
def isGuardedCase(cdef: CaseDef) = cdef.guard ne EmptyTree
- /** True iff definition is a val or def with no right-hand-side, or it
- * is an abstract typoe declaration
- */
- def lacksDefinition(mdef: MemberDef)(implicit ctx: Context) = mdef match {
- case mdef: ValOrDefDef =>
- mdef.unforcedRhs == EmptyTree && !mdef.name.isConstructorName && !mdef.mods.is(ParamAccessor)
- case mdef: TypeDef =>
- mdef.rhs.isEmpty || mdef.rhs.isInstanceOf[TypeBoundsTree]
- case _ => false
- }
-
/** The underlying pattern ignoring any bindings */
def unbind(x: Tree): Tree = unsplice(x) match {
case Bind(_, y) => unbind(y)
@@ -279,9 +268,21 @@ trait TreeInfo[T >: Untyped <: Type] { self: Trees.Instance[T] =>
trait UntypedTreeInfo extends TreeInfo[Untyped] { self: Trees.Instance[Untyped] =>
import TreeInfo._
+ import untpd._
+
+ /** True iff definition is a val or def with no right-hand-side, or it
+ * is an abstract typoe declaration
+ */
+ def lacksDefinition(mdef: MemberDef)(implicit ctx: Context) = mdef match {
+ case mdef: ValOrDefDef =>
+ mdef.unforcedRhs == EmptyTree && !mdef.name.isConstructorName && !mdef.mods.is(ParamAccessor)
+ case mdef: TypeDef =>
+ mdef.rhs.isEmpty || mdef.rhs.isInstanceOf[TypeBoundsTree]
+ case _ => false
+ }
def isFunctionWithUnknownParamType(tree: Tree) = tree match {
- case untpd.Function(args, _) =>
+ case Function(args, _) =>
args.exists {
case ValDef(_, tpt, _) => tpt.isEmpty
case _ => false
@@ -307,7 +308,7 @@ trait TypedTreeInfo extends TreeInfo[Type] { self: Trees.Instance[Type] =>
| DefDef(_, _, _, _, _) =>
Pure
case vdef @ ValDef(_, _, _) =>
- if (vdef.mods is Mutable) Impure else exprPurity(vdef.rhs)
+ if (vdef.symbol.flags is Mutable) Impure else exprPurity(vdef.rhs)
case _ =>
Impure
}
diff --git a/src/dotty/tools/dotc/ast/Trees.scala b/src/dotty/tools/dotc/ast/Trees.scala
index 528e3c589..061a0c019 100644
--- a/src/dotty/tools/dotc/ast/Trees.scala
+++ b/src/dotty/tools/dotc/ast/Trees.scala
@@ -322,7 +322,7 @@ object Trees {
private[this] var myMods: Modifiers[T] = null
- private[ast] def rawMods: Modifiers[T] =
+ private[dotc] def rawMods: Modifiers[T] =
if (myMods == null) genericEmptyModifiers else myMods
def rawComment: Option[Comment] = getAttachment(DocComment)
@@ -870,11 +870,6 @@ object Trees {
case ys => Thicket(ys)
}
- // ----- Accessing modifiers ----------------------------------------------------
-
- abstract class ModsDeco { def mods: Modifiers }
- implicit def modsDeco(mdef: MemberDef)(implicit ctx: Context): ModsDeco
-
// ----- Helper classes for copying, transforming, accumulating -----------------
val cpy: TreeCopier
diff --git a/src/dotty/tools/dotc/ast/tpd.scala b/src/dotty/tools/dotc/ast/tpd.scala
index 31a9c6975..355843cad 100644
--- a/src/dotty/tools/dotc/ast/tpd.scala
+++ b/src/dotty/tools/dotc/ast/tpd.scala
@@ -446,10 +446,6 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
} else foldOver(sym, tree)
}
- implicit class modsDeco(mdef: MemberDef)(implicit ctx: Context) extends ModsDeco {
- def mods = if (mdef.hasType) Modifiers(mdef.symbol) else mdef.rawMods
- }
-
override val cpy = new TypedTreeCopier
class TypedTreeCopier extends TreeCopier {
diff --git a/src/dotty/tools/dotc/ast/untpd.scala b/src/dotty/tools/dotc/ast/untpd.scala
index d6af6ecd0..102ee2e4e 100644
--- a/src/dotty/tools/dotc/ast/untpd.scala
+++ b/src/dotty/tools/dotc/ast/untpd.scala
@@ -264,22 +264,11 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
/** A repeated argument such as `arg: _*` */
def repeated(arg: Tree)(implicit ctx: Context) = Typed(arg, Ident(tpnme.WILDCARD_STAR))
-// ------- Decorators -------------------------------------------------
+// ----- Accessing modifiers ----------------------------------------------------
- implicit class UntypedTreeDecorator(val self: Tree) extends AnyVal {
- def locateEnclosing(base: List[Tree], pos: Position): List[Tree] = {
- def encloses(elem: Any) = elem match {
- case t: Tree => t.pos contains pos
- case _ => false
- }
- base.productIterator find encloses match {
- case Some(tree: Tree) => locateEnclosing(tree :: base, pos)
- case none => base
- }
- }
- }
+ abstract class ModsDecorator { def mods: Modifiers }
- implicit class modsDeco(val mdef: MemberDef)(implicit ctx: Context) extends ModsDeco {
+ implicit class modsDeco(val mdef: MemberDef)(implicit ctx: Context) {
def mods = mdef.rawMods
}