diff --git a/src/dotty/tools/dotc/ast/tpd.scala b/src/dotty/tools/dotc/ast/tpd.scala index 173f8189401b..b549080e404d 100644 --- a/src/dotty/tools/dotc/ast/tpd.scala +++ b/src/dotty/tools/dotc/ast/tpd.scala @@ -272,7 +272,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo { * * gets expanded to * - * lazy val obj = new obj$ + * val obj = new obj$ * class obj$ extends parents { this: obj.type => decls } * * (The following no longer applies: diff --git a/test/test/transform/LazyValsTest.scala b/test/test/transform/LazyValsTest.scala index edcc7ce0c35e..6e44f3b1560a 100644 --- a/test/test/transform/LazyValsTest.scala +++ b/test/test/transform/LazyValsTest.scala @@ -6,6 +6,15 @@ import org.junit.Assert class LazyValsTest extends DottyTest { + @Test + def doNotRewriteObjects = { + checkCompile("LazyVals", "object O"){ (tree, ctx) => + Assert.assertTrue("local lazy shouldn't rewrite module instance definitions", tree.toString.contains( + "ValDef(Modifiers(final module ,,List()),O,Ident(O$),Apply(Select(New(Ident(O$)),),List()))" + )) + } + } + @Test def localInt = { checkCompile("LazyVals", "class LocalLV { def m = { lazy val s = 1; s }}"){ (tree, ctx) =>