Java to Kotlin converter: do not initialize non-val's in artificial primary constructor - it often produced stupid code

This commit is contained in:
Valentin Kipyatkov
2014-06-26 15:25:48 +04:00
parent f8a412aea0
commit 0b7ef4debf
2 changed files with 17 additions and 9 deletions
@@ -1,12 +1,20 @@
public class Test private(private val myName: String, var a: Boolean, var b: Double, var c: Float, var d: Long, var e: Int, protected var f: Short, protected var g: Char) {
public class Test private(private val myName: String) {
var a: Boolean = false
var b: Double = 0.toDouble()
var c: Float = 0.toFloat()
var d: Long = 0
var e: Int = 0
protected var f: Short = 0
protected var g: Char = ' '
class object {
public fun create(): Test {
return Test(null, false, 0.toDouble(), 0.toFloat(), 0, 0, 0, ' ')
return Test(null)
}
public fun create(name: String): Test {
return Test(foo(name), false, 0.toDouble(), 0.toFloat(), 0, 0, 0, ' ')
return Test(foo(name))
}
fun foo(n: String): String {