mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-16 15:53:55 +00:00
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.)
15 lines
239 B
Kotlin
Vendored
15 lines
239 B
Kotlin
Vendored
class Outer() {
|
|
open inner class InnerBase() {
|
|
}
|
|
|
|
inner class InnerDerived(): InnerBase() {
|
|
}
|
|
|
|
public val foo: InnerBase? = InnerDerived()
|
|
}
|
|
|
|
fun box() : String {
|
|
val o = Outer()
|
|
return if (o.foo === null) "fail" else "OK"
|
|
}
|