From c47eba5dd805c355efa93d21ac881d1ca755eef4 Mon Sep 17 00:00:00 2001 From: Dmitry Petrashko Date: Thu, 14 Apr 2016 17:07:49 +0200 Subject: 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. --- src/dotty/tools/dotc/ast/Desugar.scala | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/dotty/tools/dotc/ast/Desugar.scala b/src/dotty/tools/dotc/ast/Desugar.scala index 719f3d036..ac2f8ae73 100644 --- a/src/dotty/tools/dotc/ast/Desugar.scala +++ b/src/dotty/tools/dotc/ast/Desugar.scala @@ -634,8 +634,11 @@ object desugar { def makeAnnotated(cls: Symbol, tree: Tree)(implicit ctx: Context) = Annotated(untpd.New(untpd.TypeTree(cls.typeRef), Nil), tree) - private def derivedValDef(named: NameTree, tpt: Tree, rhs: Tree, mods: Modifiers) = - ValDef(named.name.asTermName, tpt, rhs).withMods(mods).withPos(named.pos) + private def derivedValDef(named: NameTree, tpt: Tree, rhs: Tree, mods: Modifiers)(implicit ctx: Context) = { + val vdef = ValDef(named.name.asTermName, tpt, rhs).withMods(mods).withPos(named.pos) + val mayNeedSetter = valDef(vdef) + mayNeedSetter + } private def derivedDefDef(named: NameTree, tpt: Tree, rhs: Tree, mods: Modifiers) = DefDef(named.name.asTermName, Nil, Nil, tpt, rhs).withMods(mods).withPos(named.pos) -- cgit v1.2.3 From 4d805dd6806ab85981c77683681a7e31d6222238 Mon Sep 17 00:00:00 2001 From: Dmitry Petrashko Date: Thu, 14 Apr 2016 17:08:21 +0200 Subject: Check that #1216 is fixed. --- tests/pos/i1216.scala | 11 +++++++++++ tests/pos/i1216a.scala | 11 +++++++++++ 2 files changed, 22 insertions(+) create mode 100644 tests/pos/i1216.scala create mode 100644 tests/pos/i1216a.scala diff --git a/tests/pos/i1216.scala b/tests/pos/i1216.scala new file mode 100644 index 000000000..74c2d6c9a --- /dev/null +++ b/tests/pos/i1216.scala @@ -0,0 +1,11 @@ +object Main { + val MAX = 10 + val s1, s2, target = new Array[Long](MAX) + + var i, j = 0 + + while (i < MAX) { + target(i) = s1(i) + s2(i) + i+= 1 + } +} diff --git a/tests/pos/i1216a.scala b/tests/pos/i1216a.scala new file mode 100644 index 000000000..0652ff7a2 --- /dev/null +++ b/tests/pos/i1216a.scala @@ -0,0 +1,11 @@ +object Main { + val MAX = 10 + val s1, s2, target = new Array[Long](MAX) + + var i = 0 + + while (i < MAX) { + target(i) = s1(i) + s2(i) + i+= 1 + } +} -- cgit v1.2.3