diff --git a/compiler/src/dotty/tools/dotc/ast/Desugar.scala b/compiler/src/dotty/tools/dotc/ast/Desugar.scala index 0607b3729654..7feb727df403 100644 --- a/compiler/src/dotty/tools/dotc/ast/Desugar.scala +++ b/compiler/src/dotty/tools/dotc/ast/Desugar.scala @@ -1311,16 +1311,11 @@ object desugar { val restDefs = for (((named, tpt), n) <- vars.zipWithIndex if named.name != nme.WILDCARD) yield - if mods.is(Lazy) then - DefDef(named.name.asTermName, Nil, tpt, selector(n)) - .withMods(mods &~ Lazy) + valDef( + ValDef(named.name.asTermName, tpt, selector(n)) + .withMods(mods) .withSpan(named.span) - else - valDef( - ValDef(named.name.asTermName, tpt, selector(n)) - .withMods(mods) - .withSpan(named.span) - ) + ) flatTree(firstDef :: restDefs) } } diff --git a/tests/pos/i18878.scala b/tests/pos/i18878.scala new file mode 100644 index 000000000000..9f16983c8241 --- /dev/null +++ b/tests/pos/i18878.scala @@ -0,0 +1,6 @@ +object Foo: + lazy val (a, (b, c), d) = (1, (2, 3), 4) + def a2: a.type = a + def b2: b.type = b + def c2: c.type = c + def d2: d.type = d