Support secondary constructors for inline classes

#KT-25614 Fixed
 #KT-25246 Fixed

 KT-25599 Will be fixed after recompilation of unsigned classes
This commit is contained in:
Mikhail Zarechenskiy
2018-07-29 21:14:59 +02:00
parent 064eb24d51
commit 043ce1cb27
18 changed files with 204 additions and 17 deletions
@@ -0,0 +1,29 @@
// !LANGUAGE: +InlineClasses
// IGNORE_BACKEND: JVM_IR
var global = "wrong"
inline class Foo(val x: String) {
constructor(y: Int) : this(y.toString())
constructor(z: Long) : this(z.toInt() + 1)
constructor(other: Char) : this(other.toInt().toString()) {
global = "OK"
}
constructor(a: Int, b: Int) : this((a + b).toString())
}
fun box(): String {
var f = Foo(42)
if (f.x != "42") return "Fail 1: ${f.x}"
f = Foo(43L)
if (f.x != "44") return "Fail 2: ${f.x}"
f = Foo('a')
if (f.x != "97") return "Fail 3: ${f.x}"
f = Foo(1, 2)
if (f.x != "3") return "Fail 4: ${f.x}"
return global
}