Serialize secondary constructors

This commit is contained in:
Denis Zharkov
2015-02-25 16:06:16 +03:00
parent e65382e6ec
commit 111a138a2a
8 changed files with 62 additions and 12 deletions
@@ -0,0 +1,9 @@
open class A {
val prop: String
constructor(x1: String, x2: String = "abc") {
prop = "$x1#$x2"
}
constructor(x1: Long) {
prop = "$x1"
}
}
@@ -0,0 +1,25 @@
import java.lang
class B1() : A("123") {
constructor(x1: Int): this() {}
}
class B2 : A {
constructor(x1: String): super(x1) {}
constructor(): this("empty") {}
constructor(x1: Int): super(x1.toLong()) {}
}
fun main(args: Array<String>) {
val b1 = B1()
if (b1.prop != "123#abc") throw AssertionError("fail1: ${b1.prop}")
val b2 = B1(456)
if (b2.prop != "123#abc") throw AssertionError("fail2: ${b2.prop}")
val b3 = B2("cde")
if (b3.prop != "cde#abc") throw AssertionError("fail3: ${b3.prop}")
val b4 = B2()
if (b4.prop != "empty#abc") throw AssertionError("fail4: ${b4.prop}")
val b5 = B2(789)
if (b5.prop != "789") throw AssertionError("fail5: ${b5.prop}")
}
@@ -144,6 +144,12 @@ public class CompileKotlinAgainstKotlinTestGenerated extends AbstractCompileKotl
doTest(fileName);
}
@TestMetadata("SecondaryConstructors.A.kt")
public void testSecondaryConstructors() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/compileKotlinAgainstKotlin/SecondaryConstructors.A.kt");
doTest(fileName);
}
@TestMetadata("Simple.A.kt")
public void testSimple() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/compileKotlinAgainstKotlin/Simple.A.kt");