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

lazy vals in specialized classes are evaluated multiple times #8579

Closed
scabug opened this issue May 12, 2014 · 1 comment
Closed

lazy vals in specialized classes are evaluated multiple times #8579

scabug opened this issue May 12, 2014 · 1 comment
Milestone

Comments

@scabug
Copy link

scabug commented May 12, 2014

Testcase:

class Lazy[@specialized T]( body: => T ) {
  lazy val value = {
    println( "eval" )
    body
  }
}

object TestLazy extends App {
  val aString = new Lazy( "abc" )
  val aInt = new Lazy( 1 )

  println( aString.value )
  println( aString.value )
  println( aInt.value )
  println( aInt.value )

}

Expected output:

eval
abc
abc
eval
1
1

Actual output:

eval
abc
abc
eval
1
*eval*
1

The bitmap variable used in the specialized case is always false

@scabug
Copy link
Author

scabug commented May 12, 2014

Imported From: https://issues.scala-lang.org/browse/SI-8579?orig=1
Reporter: Martin Großmann (mgrossmann)
Affected Versions: 2.11.0

@SethTisue SethTisue modified the milestones: Backlog, 2.12.0 Mar 5, 2023
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