Skip to content
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

Erasure removes Unit typed local lazy val references #5350

Closed
allanrenucci opened this issue Oct 31, 2018 · 0 comments
Closed

Erasure removes Unit typed local lazy val references #5350

allanrenucci opened this issue Oct 31, 2018 · 0 comments

Comments

@allanrenucci
Copy link
Contributor

scala> def foo = { lazy val bar: Unit = { println("Hello") }; bar }
def foo: Unit

scala> bar
// nothing happen

Given:

class Test {
  def foo = {
    lazy val bar: Unit = println("Hello")
    bar
  }
}

After erasure:

class Test() {
  def foo(): Unit = {
    lazy <accessor> def bar(): scala.runtime.BoxedUnit = {
      println("Hello")
      scala.runtime.BoxedUnit$#UNIT
    }
    () // no more call to `bar`
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants