-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Init: Promote this
after all its fields have been initialized
#11278
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @natsukagami. While you are on it, could you incorporate some of the improvements in #10627 (excluding promotion of warm), in this PR or a new one? It will make subsequent work easier.
class P() { | ||
val a = 1 | ||
List(this) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be good to add a test that a warm inner class object promotes to hot because of the outer object being hot.
if (allFieldsInited) | ||
Errors.empty | ||
else | ||
PromoteThis(pot, eff.source, state2.path).toErrors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be good to cache safely promoted potentials to avoid re-computation. See #10627.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Description
The initialization checker will now accept uses of
this
andthis
-referencing objects as fully-initialized objects ("hot") after allval
declarations have been evaluated.Simple example:
A simple test is included.
This change is