Skip to content

Commit c47eba5

Browse files
committed
Fix #1216 Desugar: vals that are desugared PatDef may need setters.
Setters are normally synthesised in Desugar while expanding the ValDef. If the tree is a PatDef it is being desugared into several ValDefs that may need to be desugared once again.
1 parent fcf0efe commit c47eba5

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/dotty/tools/dotc/ast/Desugar.scala

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -634,8 +634,11 @@ object desugar {
634634
def makeAnnotated(cls: Symbol, tree: Tree)(implicit ctx: Context) =
635635
Annotated(untpd.New(untpd.TypeTree(cls.typeRef), Nil), tree)
636636

637-
private def derivedValDef(named: NameTree, tpt: Tree, rhs: Tree, mods: Modifiers) =
638-
ValDef(named.name.asTermName, tpt, rhs).withMods(mods).withPos(named.pos)
637+
private def derivedValDef(named: NameTree, tpt: Tree, rhs: Tree, mods: Modifiers)(implicit ctx: Context) = {
638+
val vdef = ValDef(named.name.asTermName, tpt, rhs).withMods(mods).withPos(named.pos)
639+
val mayNeedSetter = valDef(vdef)
640+
mayNeedSetter
641+
}
639642

640643
private def derivedDefDef(named: NameTree, tpt: Tree, rhs: Tree, mods: Modifiers) =
641644
DefDef(named.name.asTermName, Nil, Nil, tpt, rhs).withMods(mods).withPos(named.pos)

0 commit comments

Comments
 (0)