Skip to content

Test that lazy val doesn't rewrite module definitions. #104

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 31, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/dotty/tools/dotc/ast/tpd.scala
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
*
* gets expanded to
*
* <module> lazy val obj = new obj$
* <module> val obj = new obj$
* <module> class obj$ extends parents { this: obj.type => decls }
*
* (The following no longer applies:
Expand Down
9 changes: 9 additions & 0 deletions test/test/transform/LazyValsTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 <stable>,,List()),O,Ident(O$),Apply(Select(New(Ident(O$)),<init>),List()))"
))
}
}

@Test
def localInt = {
checkCompile("LazyVals", "class LocalLV { def m = { lazy val s = 1; s }}"){ (tree, ctx) =>
Expand Down