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
this
Given the following program
class A: // should report one error here val b = new B(this) // error val m = 10 val n = 20 class B(a: A): val x = a.m val y = a.n
Compile with -Ysafe-init, the compiler generates the following warnings:
-Ysafe-init
-- Warning: tests/init/neg/leak-constr.scala:8:12 ------------------------------ 8 | val x = a.m | ^^^ |Access field on a value with an unknown initialization status. Calling trace: |-> class A: [ leak-constr.scala:1 ] | ^ |-> val b = new B(this) // error [ leak-constr.scala:3 ] | ^^^^^^^^^^^ |-> class B(a: A): [ leak-constr.scala:7 ] | ^ |-> val x = a.m [ leak-constr.scala:8 ] | ^^^ -- Warning: tests/init/neg/leak-constr.scala:9:12 ------------------------------ 9 | val y = a.n | ^^^ |Access field on a value with an unknown initialization status. Calling trace: |-> class A: [ leak-constr.scala:1 ] | ^ |-> val b = new B(this) // error [ leak-constr.scala:3 ] | ^^^^^^^^^^^ |-> class B(a: A): [ leak-constr.scala:7 ] | ^ |-> val y = a.n [ leak-constr.scala:9 ] | ^^^ 2 warnings found
The warnings are legit, however, there are two problems:
Ideally, we should only report one error at the leaking site if the leaking is unsafe.
The text was updated successfully, but these errors were encountered:
Fix #15363: Improve error messages of leaked non-hot values
b9a3d6d
Fix scala#15363: Improve error messages of leaked non-hot values
eff2f41
ca6d644
Merge pull request #15364 from dotty-staging/fix-15363
61e57e6
Fix #15363: Improve error messages for leaking of this
liufengyun
Successfully merging a pull request may close this issue.
Minimized example
Given the following program
Output
Compile with
-Ysafe-init
, the compiler generates the following warnings:Expectation
The warnings are legit, however, there are two problems:
Ideally, we should only report one error at the leaking site if the leaking is unsafe.
The text was updated successfully, but these errors were encountered: