Skip to content

Commit 618fe96

Browse files
committed
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.
1 parent 26cb6f8 commit 618fe96

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

compiler/src/dotty/tools/dotc/ast/TreeInfo.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,11 @@ trait TreeInfo[T >: Untyped <: Type] { self: Trees.Instance[T] =>
3333
def defKind(tree: Tree): FlagSet = unsplice(tree) match {
3434
case EmptyTree | _: Import => NoInitsInterface
3535
case tree: TypeDef => if (tree.isClassDef) NoInits else NoInitsInterface
36-
case tree: DefDef => if (tree.unforcedRhs == EmptyTree) NoInitsInterface else NoInits
36+
case tree: DefDef =>
37+
if (tree.unforcedRhs == EmptyTree)
38+
(NoInitsInterface /: tree.vparamss.flatten)((fs, vparam) => fs & defKind(vparam))
39+
else
40+
NoInits
3741
case tree: ValDef => if (tree.unforcedRhs == EmptyTree) NoInitsInterface else EmptyFlags
3842
case _ => EmptyFlags
3943
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
trait Foo {
2+
def newName(prefix: String = "foo"): String
3+
}

0 commit comments

Comments
 (0)