-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix #9664: check outer of warm values #9665
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
This agrees with theory and is more accurate.
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.
this still makes the warning when A is defined by new anonymous class:
class Wrap3 {
class E
object E {
final val A = new E {}
val ref = Array(A)
}
}
Leaking inner class instances could lead to errors: class Wrap3 {
def qux(e: E) = e.foo
abstract class E { def foo: T }
object E {
final val A = new E { def foo = ref }
val ref = qux(A)
}
} Generally, checking safe early promotion of inner class instances is expensive (it needs to go through all the code in its body and its parents), thus currently the checker deems such leaking as unsafe. However, improvements are envisioned to check small inner classes to improve usability. |
ah I see that |
Adding |
ah very cool, thanks |
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
Fix #9664: check outer of warm values