You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Set module class fields to static except bitmap fields
Still we have a problem with the following magic:
https://github.com/scala/scala/pull/7270/files#r221195225
It is a magic for two reasons:
1. It generates `getstatic` for `Select(This(O$), x)`
2. It is not affected by compilation order of classes
For the second, suppose the backend compiles `A$B` before `A`.
Then the class `A$B` does not see that `x` is static,
which should cause problem at runtime:
```
object A {
private[this] val x: Int = 10
class B {
val y = x
}
}
```
The following are the reasons why it works in scalac:
1. inner classes always come after the outer class
2. non `private[this]` fields are accessed via accessor methods, which are not static
3. inside the module class, access to the fields are compiled after setting the static flag
4. the code generation specialize for trees like `Select(This(O$), x)`, where `x` is a static member
0 commit comments