82ccf81da8
Inner class constructors should use the argument instead of reading outer `this` from a field because if such an access happens before a delegating constructor call, e.g. when evaluating an argument, a JVM bytecode validation error will be thrown. (The only operation on `this` allowed before a delegating constructor call is SETFIELD, and only if the field in question is declared in the same class.)
18 lines
324 B
Kotlin
Vendored
18 lines
324 B
Kotlin
Vendored
interface Test {
|
|
fun test(): String
|
|
}
|
|
|
|
open class Base(val test: Test)
|
|
|
|
open class Outer(val x: String) {
|
|
open inner class Inner
|
|
|
|
inner class JavacBug : Base(
|
|
object : Outer.Inner(), Test {
|
|
override fun test() = x
|
|
}
|
|
)
|
|
}
|
|
|
|
fun box() = Outer("OK").JavacBug().test.test()
|