Java to Kotlin converter: more correct detection of primary constructor + constructor chains are supported (not completely correct code generated yet)

This commit is contained in:
Valentin Kipyatkov
2014-06-26 18:51:41 +04:00
parent 9d1452bbbc
commit f698ca69d7
8 changed files with 206 additions and 84 deletions
@@ -0,0 +1,23 @@
//file
class C {
C(int arg1, int arg2, int arg3) {
}
C(int arg1, int arg2) {
this(arg1, arg2, 0);
System.out.println();
}
C(int arg1) {
this(arg1, 0);
System.out.println();
}
}
public class User {
public static void main() {
C c1 = new C(1, 2, 3);
C c2 = new C(5, 6);
C c3 = new C(7);
}
}
@@ -0,0 +1,26 @@
class C(arg1: Int, arg2: Int, arg3: Int) {
class object {
fun create(arg1: Int, arg2: Int): C {
val __ = C(arg1, arg2, 0)
System.out.println()
return __
}
fun create(arg1: Int): C {
val __ = C(arg1, 0)
System.out.println()
return __
}
}
}
public class User {
class object {
public fun main() {
val c1 = C(1, 2, 3)
val c2 = C.create(5, 6)
val c3 = C.create(7)
}
}
}
@@ -0,0 +1,22 @@
//file
class C {
C(int arg1, int arg2, int arg3) {
}
C(int arg1, int arg2) {
this(arg1, arg2, 0);
System.out.println();
}
C(int arg) {
System.out.println(arg);
}
}
public class User {
public static void main() {
C c1 = new C(1, 2, 3);
C c2 = new C(5, 6);
C c3 = new C(7);
}
}
@@ -0,0 +1,29 @@
class C private() {
class object {
fun create(arg1: Int, arg2: Int, arg3: Int): C {
return C()
}
fun create(arg1: Int, arg2: Int): C {
val __ = C(arg1, arg2, 0)
System.out.println()
return __
}
fun create(arg: Int): C {
val __ = C()
System.out.println(arg)
return __
}
}
}
public class User {
class object {
public fun main() {
val c1 = C.create(1, 2, 3)
val c2 = C.create(5, 6)
val c3 = C.create(7)
}
}
}