Java to Kotlin converter: access modifiers of factory functions + factory functions for nested classes

This commit is contained in:
Valentin Kipyatkov
2014-06-27 14:16:54 +04:00
parent 3c34197bc0
commit e86d74600d
11 changed files with 388 additions and 14 deletions
@@ -2,7 +2,7 @@ private fun C(arg1: Int, arg2: Int): C {
return C(arg1, arg2, 0)
}
public fun C(arg1: Int): C {
fun C(arg1: Int): C {
return C(arg1, 0, 0)
}
@@ -0,0 +1,74 @@
//file
class Outer {
private class Inner1 {
public Inner1(){}
public Inner1(int a) {
this();
}
protected Inner1(char c) {
this();
}
private Inner1(boolean b) {
this();
}
}
protected class Inner2 {
public Inner2(){}
public Inner2(int a) {
this();
}
protected Inner2(char c) {
this();
}
private Inner2(boolean b) {
this();
}
}
class Inner3 {
public Inner3(){}
public Inner3(int a) {
this();
}
protected Inner3(char c) {
this();
}
private Inner3(boolean b) {
this();
}
}
public class Inner4 {
public Inner4(){}
public Inner4(int a) {
this();
}
protected Inner4(char c) {
this();
}
private Inner4(boolean b) {
this();
}
}
void foo() {
Inner1 inner1 = new Inner1(1);
Inner2 inner2 = new Inner2(2);
Inner3 inner3 = new Inner3(3);
Inner4 inner4 = new Inner4(4);
}
}
@@ -0,0 +1,68 @@
class Outer {
private fun Inner1(a: Int): Inner1 {
return Inner1()
}
private fun Inner1(c: Char): Inner1 {
return Inner1()
}
private fun Inner1(b: Boolean): Inner1 {
return Inner1()
}
private inner class Inner1
protected fun Inner2(a: Int): Inner2 {
return Inner2()
}
protected fun Inner2(c: Char): Inner2 {
return Inner2()
}
private fun Inner2(b: Boolean): Inner2 {
return Inner2()
}
protected inner class Inner2
fun Inner3(a: Int): Inner3 {
return Inner3()
}
fun Inner3(c: Char): Inner3 {
return Inner3()
}
private fun Inner3(b: Boolean): Inner3 {
return Inner3()
}
inner class Inner3
public fun Inner4(a: Int): Inner4 {
return Inner4()
}
public fun Inner4(c: Char): Inner4 {
return Inner4()
}
private fun Inner4(b: Boolean): Inner4 {
return Inner4()
}
public inner class Inner4
fun foo() {
val inner1 = Inner1(1)
val inner2 = Inner2(2)
val inner3 = Inner3(3)
val inner4 = Inner4(4)
}
}
@@ -0,0 +1,74 @@
//file
class Outer {
private static class Nested1 {
public Nested1(){}
public Nested1(int a) {
this();
}
protected Nested1(char c) {
this();
}
private Nested1(boolean b) {
this();
}
}
protected static class Nested2 {
public Nested2(){}
public Nested2(int a) {
this();
}
protected Nested2(char c) {
this();
}
private Nested2(boolean b) {
this();
}
}
static class Nested3 {
public Nested3(){}
public Nested3(int a) {
this();
}
protected Nested3(char c) {
this();
}
private Nested3(boolean b) {
this();
}
}
public static class Nested4 {
public Nested4(){}
public Nested4(int a) {
this();
}
protected Nested4(char c) {
this();
}
private Nested4(boolean b) {
this();
}
}
static void foo() {
Nested1 nested1 = new Nested1(1);
Nested2 nested2 = new Nested2(2);
Nested3 nested3 = new Nested3(3);
Nested4 nested4 = new Nested4(4);
}
}
@@ -0,0 +1,70 @@
class Outer {
class object {
private fun Nested1(a: Int): Nested1 {
return Nested1()
}
private fun Nested1(c: Char): Nested1 {
return Nested1()
}
private fun Nested1(b: Boolean): Nested1 {
return Nested1()
}
private class Nested1
protected fun Nested2(a: Int): Nested2 {
return Nested2()
}
protected fun Nested2(c: Char): Nested2 {
return Nested2()
}
private fun Nested2(b: Boolean): Nested2 {
return Nested2()
}
protected class Nested2
fun Nested3(a: Int): Nested3 {
return Nested3()
}
fun Nested3(c: Char): Nested3 {
return Nested3()
}
private fun Nested3(b: Boolean): Nested3 {
return Nested3()
}
class Nested3
public fun Nested4(a: Int): Nested4 {
return Nested4()
}
public fun Nested4(c: Char): Nested4 {
return Nested4()
}
private fun Nested4(b: Boolean): Nested4 {
return Nested4()
}
public class Nested4
fun foo() {
val nested1 = Nested1(1)
val nested2 = Nested2(2)
val nested3 = Nested3(3)
val nested4 = Nested4(4)
}
}
}
@@ -0,0 +1,24 @@
//file
class A {
public A() {}
public A(int a) { this(); }
protected A(char c) { this(); }
A(float f) { this(); }
private A(double d) { this(); }
}
public class B {
public B() {}
public B(int a) { this(); }
protected B(char c) { this(); }
B(float f) { this(); }
private B(double d) { this(); }
}
@@ -0,0 +1,36 @@
fun A(a: Int): A {
return A()
}
fun A(c: Char): A {
return A()
}
fun A(f: Float): A {
return A()
}
private fun A(d: Double): A {
return A()
}
class A
public fun B(a: Int): B {
return B()
}
public fun B(c: Char): B {
return B()
}
fun B(f: Float): B {
return B()
}
private fun B(d: Double): B {
return B()
}
public class B