-
Notifications
You must be signed in to change notification settings - Fork 1.1k
-Ycheck-init warning with Some(this) #9795
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
Comments
Thanks for the report @japgolly . Escape of |
It's a micro-optimisation. Consider this example: final case class Id(value: Long) {
val some: Some[this.type] =
Some(this)
} It might look odd but sometimes I do this for real performance benefits when there's a very-hot loop (eg. graph traversal / calculation) and your application's logic is heavily affected by the presence or lack of a related node's ID. By storing |
Oh and btw, if it makes a difference, the reason I used |
@japgolly Thanks for the detailed explanation. For now, you can use |
This issue was picked for the Issue Spree number 16 of May 24th which takes place in a week from now. @liufengyun @gagandeepkalra @anatoliykmetyuk will be working on it. If you have any insight into the issue or guidance on how to fix it, please leave it here. |
The following paper will be helpful to understand the initialization checker: https://dl.acm.org/doi/10.1145/3486610.3486895 |
Fixed by #15307. |
Minimized code
Dotty ver: 0.27.0-RC1
Output
Expectation
No warning
The text was updated successfully, but these errors were encountered: