Java to Kotlin converter: fixed bugs with reference conversion in secondary constructors

This commit is contained in:
Valentin Kipyatkov
2014-06-25 21:48:06 +04:00
parent f277285d9a
commit f8e4ecfa94
7 changed files with 80 additions and 3 deletions
@@ -0,0 +1,20 @@
//file
class C {
private final int arg1;
private final int arg2;
private final int arg3;
int foo(int p){ return p; }
private static int staticFoo(int p){ return p; }
C(int arg1, int arg2, int arg3) {
this.arg1 = arg1;
this.arg2 = arg2;
this.arg3 = arg3;
}
C(int arg1, int arg2, C other) {
this(arg1, arg2, 0);
System.out.println(foo(1) + this.foo(2) + other.foo(3) + staticFoo(4) + C.staticFoo(5));
}
}
@@ -0,0 +1,18 @@
class C(private val arg1: Int, private val arg2: Int, private val arg3: Int) {
fun foo(p: Int): Int {
return p
}
class object {
private fun staticFoo(p: Int): Int {
return p
}
fun create(arg1: Int, arg2: Int, other: C): C {
val __ = C(arg1, arg2, 0)
System.out.println(__.foo(1) + __.foo(2) + other.foo(3) + staticFoo(4) + C.staticFoo(5))
return __
}
}
}
@@ -0,0 +1,13 @@
//file
class C {
private static int staticField1 = 0;
private static int staticField2 = 0;
C() {
}
C(int p) {
this();
System.out.println(staticField1 + C.staticField2);
}
}
@@ -0,0 +1,12 @@
class C {
class object {
private val staticField1 = 0
private val staticField2 = 0
fun create(p: Int): C {
val __ = C()
System.out.println(staticField1 + C.staticField2)
return __
}
}
}