We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
next code:
object A { val init = println("hello") } object Main { def main(args: Array[String]) { val a = A.init } }
produces no output, but "hello" is expected. This behaviour was observed when trying code described here http://stackoverflow.com/questions/24221601/scala-object-initialization
The text was updated successfully, but these errors were encountered:
Imported From: https://issues.scala-lang.org/browse/SI-8666?orig=1 Reporter: Maksym Besida (mbesida) Affected Versions: 2.10.3 See #5304
Sorry, something went wrong.
@retronym said: This relates to #5304, which shows other examples where the object initialization is elided.
This particular instance comes down to:
//src/compiler/scala/tools/nsc/transform/TypeAdaptingTransformer.scala case UnitClass => if (treeInfo isExprSafeToInline tree) REF(BoxedUnit_UNIT) else BLOCK(tree, REF(BoxedUnit_UNIT))
isExprSafeToInline is insufficient, we have to check whether the tree is safe to elide.
isExprSafeToInline
I added a reference from #5304 to here. closing
retronym
No branches or pull requests
next code:
produces no output, but "hello" is expected.
This behaviour was observed when trying code described here http://stackoverflow.com/questions/24221601/scala-object-initialization
The text was updated successfully, but these errors were encountered: