diff options
author | Martin Odersky <odersky@gmail.com> | 2015-06-16 16:27:10 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2015-06-16 16:42:54 +0200 |
commit | 112f39aa1c3a9e36848b30d7d2709fb1b2ef7949 (patch) | |
tree | 5f61e94cc0b8684808431fd6424063907d0690eb /src/dotty/tools/dotc/ast/TreeInfo.scala | |
parent | 4eb107258458801b72e5c34ab4ccf3729b9e12d6 (diff) | |
download | dotty-112f39aa1c3a9e36848b30d7d2709fb1b2ef7949.tar.gz dotty-112f39aa1c3a9e36848b30d7d2709fb1b2ef7949.tar.bz2 dotty-112f39aa1c3a9e36848b30d7d2709fb1b2ef7949.zip |
Use FlagSet directly instead of defKind
Instead of classifying class members with a TreeInfo.DefKind, we
use directly the flags into which kinds were previously translated.
Diffstat (limited to 'src/dotty/tools/dotc/ast/TreeInfo.scala')
-rw-r--r-- | src/dotty/tools/dotc/ast/TreeInfo.scala | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/src/dotty/tools/dotc/ast/TreeInfo.scala b/src/dotty/tools/dotc/ast/TreeInfo.scala index b20b7c9f2..c9a22f09e 100644 --- a/src/dotty/tools/dotc/ast/TreeInfo.scala +++ b/src/dotty/tools/dotc/ast/TreeInfo.scala @@ -25,14 +25,16 @@ trait TreeInfo[T >: Untyped <: Type] { self: Trees.Instance[T] => case _ => false } - /** Does tree contain an initialization part when seen as a member of a class or trait? + /** The largest subset of {NoInits, PureInterface} that a + * trait enclosing this statement can have as flags. + * Does tree contain an initialization part when seen as a member of a class or trait? */ - def defKind(tree: Tree): DefKind = unsplice(tree) match { - case EmptyTree | _: Import => InterfaceDef - case tree: TypeDef => if (tree.isClassDef) NoInitDef else InterfaceDef - case tree: DefDef => if (tree.unforcedRhs == EmptyTree) InterfaceDef else NoInitDef - case tree: ValDef => if (tree.unforcedRhs == EmptyTree) InterfaceDef else GeneralDef - case _ => GeneralDef + def defKind(tree: Tree): FlagSet = unsplice(tree) match { + case EmptyTree | _: Import => NoInitsInterface + case tree: TypeDef => if (tree.isClassDef) NoInits else NoInitsInterface + case tree: DefDef => if (tree.unforcedRhs == EmptyTree) NoInitsInterface else NoInits + case tree: ValDef => if (tree.unforcedRhs == EmptyTree) NoInitsInterface else EmptyFlags + case _ => EmptyFlags } def isOpAssign(tree: Tree) = unsplice(tree) match { @@ -517,7 +519,6 @@ trait TypedTreeInfo extends TreeInfo[Type] { self: Trees.Instance[Type] => } object TreeInfo { - class PurityLevel(val x: Int) extends AnyVal { def >= (that: PurityLevel) = x >= that.x def min(that: PurityLevel) = new PurityLevel(x min that.x) @@ -526,15 +527,6 @@ object TreeInfo { val Pure = new PurityLevel(2) val Idempotent = new PurityLevel(1) val Impure = new PurityLevel(0) - - case class DefKind(val x: Int) extends AnyVal { - def >= (that: DefKind) = x >= that.x - def min(that: DefKind) = new DefKind(x min that.x) - } - - val InterfaceDef = new DefKind(2) - val NoInitDef = new DefKind(1) - val GeneralDef = new DefKind(0) } /** a Match(Typed(_, tpt), _) must be translated into a switch if isSwitchAnnotation(tpt.tpe) |