Java to Kotlin converter: constructor overloads to default parameter values conversion

This commit is contained in:
Valentin Kipyatkov
2014-06-27 16:48:22 +04:00
parent e86d74600d
commit 13f40e5b0d
20 changed files with 316 additions and 71 deletions
@@ -7,10 +7,15 @@ class A {
v = 1;
} // end of primary constructor body
// this is a secondary constructor
// this is a secondary constructor 1
A() {
this(1);
} // end of secondary constructor body
} // end of secondary constructor 1 body
// this is a secondary constructor 2
A(String s) {
this(s.length());
} // end of secondary constructor 2 body
}
class B {
@@ -1,16 +1,17 @@
// this is a secondary constructor
fun A(): A {
return A(1)
} // end of secondary constructor body
// this is a secondary constructor 2
fun A(s: String): A {
return A(s.length())
} // end of secondary constructor 2 body
class A// this is a primary constructor
(p: Int) {
(p: Int = 1) {
private val v: Int
{
v = 1
} // end of primary constructor body
}
}// this is a secondary constructor 1
// end of secondary constructor 1 body
class B// this constructor will disappear
(private val x: Int) // end of constructor body
@@ -1,15 +1,6 @@
package pack
fun C(arg1: Int, arg2: Int): C {
return C(arg1, arg2, 0)
}
fun C(arg1: Int): C {
return C(arg1, 0, 0)
}
class C(arg1: Int, arg2: Int, arg3: Int)
class C(arg1: Int, arg2: Int = 0, arg3: Int = 0)
public class User {
class object {
@@ -0,0 +1,19 @@
//file
package pack
class C {
C(int a, int b, int c, int d, int e) {
}
C(int a, int b, int c) {
this(a, b, c, 0, 0);
}
C(int a) {
this(a, 0, 0, 0, 1);
}
C() {
this(0, 0, 0, 0, 0);
}
}
@@ -0,0 +1,8 @@
package pack
fun C(a: Int): C {
return C(a, 0, 0, 0, 1)
}
class C(a: Int = 0, b: Int = 0, c: Int = 0, d: Int = 0, e: Int = 0)
@@ -0,0 +1,19 @@
//file
package pack
class C {
C(int a, int b, int c, int d, int e) {
}
C(int a1, int b1, int c1) {
this(a1, b1, c1, 0, 0);
}
C(byte b) {
this(b, 0, 0, 0, 0);
}
C() {
this(0, 0, 0, 0, 0);
}
}
@@ -0,0 +1,12 @@
package pack
fun C(a1: Int, b1: Int, c1: Int): C {
return C(a1, b1, c1, 0, 0)
}
fun C(b: Byte): C {
return C(b.toInt(), 0, 0, 0, 0)
}
class C(a: Int = 0, b: Int = 0, c: Int = 0, d: Int = 0, e: Int = 0)
@@ -0,0 +1,15 @@
//file
package pack
class C {
C(int a, int b, int c, int d, int e) {
}
C(int a, int b, int c) {
this(b, a, c, 0, 0);
}
C() {
this(0, 0, 0, 0, 0);
}
}
@@ -0,0 +1,8 @@
package pack
fun C(a: Int, b: Int, c: Int): C {
return C(b, a, c, 0, 0)
}
class C(a: Int = 0, b: Int = 0, c: Int = 0, d: Int = 0, e: Int = 0)
@@ -0,0 +1,23 @@
//file
package pack
class C {
C(int a, int b, int c, int d, int e) {
}
C(int a, int b, int c) {
this(a, b, c, 4, 5);
}
C(int a) {
this(a, 2, 3);
}
C(int a, int b) {
this(a, b, 3, 4, 5);
}
C() {
this(1);
}
}
@@ -0,0 +1,3 @@
package pack
class C(a: Int = 1, b: Int = 2, c: Int = 3, d: Int = 4, e: Int = 5)
@@ -0,0 +1,23 @@
//file
package pack
class C {
C(int a, int b, int c, int d, int e) {
}
C() {
this(1);
}
C(int a, int b) {
this(a, b, 3, 4, 5);
}
C(int a) {
this(a, 2, 3);
}
C(int a, int b, int c) {
this(a, b, c, 4, 5);
}
}
@@ -0,0 +1,3 @@
package pack
class C(a: Int = 1, b: Int = 2, c: Int = 3, d: Int = 4, e: Int = 5)
@@ -5,11 +5,7 @@ fun C(arg1: Int, arg2: Int): C {
return __
}
fun C(arg1: Int): C {
return C(arg1, 0, 0)
}
class C(arg1: Int, arg2: Int, arg3: Int) {
class C(arg1: Int, arg2: Int = 0, arg3: Int = 0) {
private val field: Int
{
@@ -1,9 +1,5 @@
private fun C(arg1: Int, arg2: Int): C {
return C(arg1, arg2, 0)
}
fun C(arg1: Int): C {
return C(arg1, 0, 0)
}
class C private(arg1: Int, arg2: Int, arg3: Int)
class C private(arg1: Int, arg2: Int, arg3: Int = 0)