KT-12152 : constructor consistency: handle non-final classes

This commit is contained in:
Mikhail Glukhikh
2015-08-11 15:35:56 +03:00
parent 8e18165065
commit f7b5d67543
7 changed files with 97 additions and 10 deletions
@@ -0,0 +1,34 @@
open class Base {
init {
register(<!DEBUG_INFO_LEAKING_THIS!>this<!>)
<!DEBUG_INFO_LEAKING_THIS!>foo<!>()
}
open fun foo() {}
}
fun register(arg: Base) {
arg.foo()
}
class Derived(val x: Int) : Base() {
override fun foo() {
x.hashCode() // NPE in Base constructor
}
}
enum class MyEnum {
FIRST() {
val x: Int = 42
override fun foo() {
x.hashCode() // NPE in MyEnum constructor
}
};
init {
<!DEBUG_INFO_LEAKING_THIS!>foo<!>()
}
abstract fun foo()
}