diff options
author | Martin Odersky <odersky@gmail.com> | 2017-03-08 16:51:06 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2017-03-08 16:52:43 +0100 |
commit | 22e9219dd46eeb3b4ba3823d6dc45bc42c41dca1 (patch) | |
tree | 7a6f87b1e615c218258666004cca2766895640a4 /compiler/src/dotty/tools/dotc/ast | |
parent | c84480960cf618c29705dbaab9332d304a081524 (diff) | |
download | dotty-22e9219dd46eeb3b4ba3823d6dc45bc42c41dca1.tar.gz dotty-22e9219dd46eeb3b4ba3823d6dc45bc42c41dca1.tar.bz2 dotty-22e9219dd46eeb3b4ba3823d6dc45bc42c41dca1.zip |
Fix #2067: Compute defKind at Typer, not Namer
It's hard to predict for defKind all the desugarings that can be
applied to a definition. Better to do it once the desugarings have been
applied. NoInit and PureInterface are both tested only after Typer,
so it's OK to delay their initialization until regular Typer.
Diffstat (limited to 'compiler/src/dotty/tools/dotc/ast')
-rw-r--r-- | compiler/src/dotty/tools/dotc/ast/TreeInfo.scala | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/compiler/src/dotty/tools/dotc/ast/TreeInfo.scala b/compiler/src/dotty/tools/dotc/ast/TreeInfo.scala index dd890dc50..b00d7df71 100644 --- a/compiler/src/dotty/tools/dotc/ast/TreeInfo.scala +++ b/compiler/src/dotty/tools/dotc/ast/TreeInfo.scala @@ -26,23 +26,6 @@ trait TreeInfo[T >: Untyped <: Type] { self: Trees.Instance[T] => case _ => false } - /** 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): FlagSet = unsplice(tree) match { - case EmptyTree | _: Import => - NoInitsInterface - case tree: TypeDef => - if (tree.isClassDef) NoInits else NoInitsInterface - case tree: DefDef => - if (tree.unforcedRhs == EmptyTree && tree.vparamss.forall(_.forall(_.unforcedRhs == EmptyTree))) NoInitsInterface else NoInits - case tree: ValDef => - if (tree.unforcedRhs == EmptyTree) NoInitsInterface else EmptyFlags - case _ => - EmptyFlags - } - def isOpAssign(tree: Tree) = unsplice(tree) match { case Apply(fn, _ :: _) => unsplice(fn) match { @@ -588,6 +571,16 @@ trait TypedTreeInfo extends TreeInfo[Type] { self: Trees.Instance[Type] => accum(Nil, root) } + /** The largest subset of {NoInits, PureInterface} that a + * trait enclosing this statement can have as flags. + */ + 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 + } /** The top level classes in this tree, including only those module classes that * are not a linked class of some other class in the result. |