Closed
Description
Currently, the phase MoveStatic
has two functionality:
- Move
@static
members from the companion objectA
to the classA
- Create static constructor for static fields of the class
A
In an earlier phase, CheckStatic
checks that @static
members only locate in the companion object A. This restriction is just for semantic-correctness of user-written programs (to avoid changing the typer). For code that is synthesized from compiler phases, this restriction is annoying.
We can make @static
a general mechanism in the compiler by splitting MoveStatic
into two phases:
- one phase that performs the moving (can be merged with
CheckStatic
) - one phase
StaticConstructors
that synthesize the static constructor for static fields.
The phase CompleteJavaEnums
will benefit from the refactoring #8008.