-
Notifications
You must be signed in to change notification settings - Fork 113
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
Add FinalVal wart #237
Add FinalVal wart #237
Conversation
any update on this? should i add the following example to readme? $ echo "object a { final val v = 1 }" > a.scala
$ echo "object b extends App { println(a.v) }" > b.scala
$ sbt ~run
1
$ echo "object a { final val v = 2 }" > a.scala
1 |
What is the proposed workaround for this situation? |
Also, is there a bug filed against scala that we can link to? |
It's in the spec, it's expected behaviour. |
workaround is to use non-final it's not a Scala bug, but it's still quite unsafe |
@dwijnand Inlining is certainly in the spec but the incremental compiler not recompiling dependent files due to inlining is not (to my knowledge). @tim-zh My concern there is that making a |
Yeah, I agree with you there. We should open a ticket against Zinc to fix it. |
Btw it's constant-folding, not inlining. And making it a def or adding a type ascription to the val are other alternatives. val v: Int = 1
def v: Int = 1
final val v: Int = 1 |
@dwijnand Indeed, thanks. It's a bit trickier than i thought, and it means the pr can't be merged :(, since we can't prevent false positives right now. |
@tim-zh I think the only false-positive you're missing is |
This looks set to merge to me and it'll go out in 1.1.0. The one additional thing I'd like to see is a ticket for the bug against Zinc so we can link to it in the README. Since this wart is related to an actual bug I want to know when it stops being relevant (due to a bugfix). |
@ChrisNeveu sbt/sbt/issues/1543 ? |
Thanks! I'll add a link to that in the README. |
by the way, the incremental compiler now tracks these kind of constant vals |
No description provided.