aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/dotty/tools/dotc/ast/TreeInfo.scala
diff options
context:
space:
mode:
authorGuillaume Martres <smarter@ubuntu.com>2017-03-07 18:51:21 +0100
committerGuillaume Martres <smarter@ubuntu.com>2017-03-08 13:30:48 +0100
commita2b3bc17271a59f4d0f690fd46f3328c55ab06cb (patch)
tree5e0eaa03bb816ab2c7fa21897f5caf201005f88d /compiler/src/dotty/tools/dotc/ast/TreeInfo.scala
parent279dd3b2065fcdbb2c561a9a68487696dd4923b4 (diff)
downloaddotty-a2b3bc17271a59f4d0f690fd46f3328c55ab06cb.tar.gz
dotty-a2b3bc17271a59f4d0f690fd46f3328c55ab06cb.tar.bz2
dotty-a2b3bc17271a59f4d0f690fd46f3328c55ab06cb.zip
Don't set PureInterface when a default param is present
The default param will be desugared into a method with a body, so setting PureInterface would be wrong. The enclosed test previously failed with a pickling difference, because the unpickler correctly decided to not set the PureInterface flag since it saw the default param method. This fixes the tasty_dotc_util which failed since the last commit because FreshNameCreator was now incorrectly recognized as a PureInterface.
Diffstat (limited to 'compiler/src/dotty/tools/dotc/ast/TreeInfo.scala')
-rw-r--r--compiler/src/dotty/tools/dotc/ast/TreeInfo.scala15
1 files changed, 10 insertions, 5 deletions
diff --git a/compiler/src/dotty/tools/dotc/ast/TreeInfo.scala b/compiler/src/dotty/tools/dotc/ast/TreeInfo.scala
index e48b1039b..dd890dc50 100644
--- a/compiler/src/dotty/tools/dotc/ast/TreeInfo.scala
+++ b/compiler/src/dotty/tools/dotc/ast/TreeInfo.scala
@@ -31,11 +31,16 @@ trait TreeInfo[T >: Untyped <: Type] { self: Trees.Instance[T] =>
* 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) NoInitsInterface else NoInits
- case tree: ValDef => if (tree.unforcedRhs == EmptyTree) NoInitsInterface else EmptyFlags
- case _ => EmptyFlags
+ 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 {