Java to Kotlin converter: constructor overloads to default parameter values conversion
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user