Skip to content

Commit 3335cd0

Browse files
committed
Merge pull request #104 from DarkDimius/lazy-vals-obj
Test that lazy val doesn't rewrite module definitions.
2 parents 5d9feef + 6031010 commit 3335cd0

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
272272
*
273273
* gets expanded to
274274
*
275-
* <module> lazy val obj = new obj$
275+
* <module> val obj = new obj$
276276
* <module> class obj$ extends parents { this: obj.type => decls }
277277
*
278278
* (The following no longer applies:

test/test/transform/LazyValsTest.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@ import org.junit.Assert
66

77
class LazyValsTest extends DottyTest {
88

9+
@Test
10+
def doNotRewriteObjects = {
11+
checkCompile("LazyVals", "object O"){ (tree, ctx) =>
12+
Assert.assertTrue("local lazy shouldn't rewrite module instance definitions", tree.toString.contains(
13+
"ValDef(Modifiers(final module <stable>,,List()),O,Ident(O$),Apply(Select(New(Ident(O$)),<init>),List()))"
14+
))
15+
}
16+
}
17+
918
@Test
1019
def localInt = {
1120
checkCompile("LazyVals", "class LocalLV { def m = { lazy val s = 1; s }}"){ (tree, ctx) =>

0 commit comments

Comments
 (0)