Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
maybe scala/scala#7270 ? ``` package example import scala.reflect.NameTransformer object A{ Main.a = 1 } object B{ Main.b = 1 } object Main { var a: Int = 0 var b: Int = 0 def initializeByConstructor(): Int = { this.a = 0 val List(constructor) = Class.forName("example.A$").getDeclaredConstructors.toList constructor.setAccessible(true) constructor.newInstance() val result = Main.a this.a = 0 result } def initializeByMODULE_field(): Int = { this.b = 0 Class.forName("example.B$").getDeclaredField(NameTransformer.MODULE_INSTANCE_NAME).get(null) val result = Main.b this.b = 0 result } def main(args: Array[String]): Unit = { println((A, B)) println(scala.util.Properties.versionString) println(initializeByConstructor()) println(initializeByMODULE_field()) } } ``` ``` [info] version 2.12.11 [info] 1 [info] 0 ``` ``` [info] version 2.13.2 [info] 0 [info] 0 ```
- Loading branch information