Skip to content

Refactor MoveStatic #8022

Closed
Closed
@liufengyun

Description

@liufengyun

Currently, the phase MoveStatic has two functionality:

  • Move @static members from the companion object A to the class A
  • 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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions