Don't initialize const properties in constructor

#KT-9532 Fixed
This commit is contained in:
Michael Bogdanov
2015-10-17 12:32:41 +03:00
committed by Michael Bogdanov
parent 7d7d37719b
commit 3452fc8d02
10 changed files with 123 additions and 0 deletions
@@ -0,0 +1,18 @@
interface KInt {
companion object {
const val a = "a"
const val b = "b$a"
}
}
fun box(): String {
val a = KInt::class.java.getField("a").get(null)
val b = KInt::class.java.getField("b").get(null)
if (a !== KInt.a) return "fail 1: KInt.a !== KInt.Companion.a"
if (b !== KInt.b) return "fail 2: KInt.b !== KInt.Companion.b"
if (b !== "ba") return "fail 2: 'ba' !== KInt.Companion.b"
return "OK"
}