-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Fix #5350: Fix purity of local lazy vals #5703
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
scala> def foo = { lazy val bar: Unit = { println("Hello") }; bar } | ||
def foo: Unit | ||
scala> foo | ||
Hello | ||
scala> { lazy val bar: Unit = { println("Hello") }; bar } | ||
Hello | ||
lazy val bar: Unit |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Hello |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
object Test { | ||
def foo = { | ||
lazy val bar: Unit = println("Hello") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Blaisorblade does it make sense for this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. The definition of To detect if a value is pure, Realizability checks That all needs testcases and consideration? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually modules do not reach this line. Hence the current condition does not affect the module init elimination. |
||
bar | ||
} | ||
|
||
def main(args: Array[String]): Unit = { | ||
foo | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Hello |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
object Test { | ||
def foo: Unit = { | ||
object bar { println("Hello") } | ||
bar | ||
} | ||
|
||
def main(args: Array[String]): Unit = { | ||
foo | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Hello |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
object Test { | ||
def foo: Unit = { | ||
bar | ||
} | ||
|
||
def main(args: Array[String]): Unit = { | ||
foo | ||
} | ||
} | ||
object bar { println("Hello") } |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Hello | ||
apply |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
object Test { | ||
def foo: Unit = { | ||
bar() | ||
} | ||
|
||
def main(args: Array[String]): Unit = { | ||
foo | ||
} | ||
} | ||
object bar { | ||
println("Hello") | ||
def apply(): Unit = println("apply") | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 on printing the flag to the left (in
ReplPrinter
). On this change, FWIW, Scala 2 also uses<lazy>
here. Not sure anybody cares tho, so merging anyway.