KT-5287 J2K: Convert class with private constructor and static functions to "object" instead of class with "class object"
#KT-5287 Fixed
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
class Test {
|
||||
companion object {
|
||||
public fun foo(args: Array<String>): Int {
|
||||
return args.size()
|
||||
}
|
||||
object Test {
|
||||
public fun foo(args: Array<String>): Int {
|
||||
return args.size()
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,9 @@
|
||||
class Outer {
|
||||
object Outer {
|
||||
public var o: Any? = Object()
|
||||
|
||||
public class Nested {
|
||||
public fun foo() {
|
||||
o = null
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
public var o: Any? = Object()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
package demo
|
||||
|
||||
class Test {
|
||||
companion object {
|
||||
fun subListRangeCheck(fromIndex: Int, toIndex: Int, size: Int) {
|
||||
if (fromIndex < 0)
|
||||
throw IndexOutOfBoundsException("fromIndex = " + fromIndex)
|
||||
if (toIndex > size)
|
||||
throw IndexOutOfBoundsException("toIndex = " + toIndex)
|
||||
if (fromIndex > toIndex)
|
||||
throw IllegalArgumentException("fromIndex(" + fromIndex + ") > toIndex(" + toIndex + ")")
|
||||
}
|
||||
object Test {
|
||||
fun subListRangeCheck(fromIndex: Int, toIndex: Int, size: Int) {
|
||||
if (fromIndex < 0)
|
||||
throw IndexOutOfBoundsException("fromIndex = " + fromIndex)
|
||||
if (toIndex > size)
|
||||
throw IndexOutOfBoundsException("toIndex = " + toIndex)
|
||||
if (fromIndex > toIndex)
|
||||
throw IllegalArgumentException("fromIndex(" + fromIndex + ") > toIndex(" + toIndex + ")")
|
||||
}
|
||||
}
|
||||
@@ -20,13 +20,11 @@ public class Identifier<T> {
|
||||
}
|
||||
}
|
||||
|
||||
public class User {
|
||||
companion object {
|
||||
public fun main(args: Array<String>) {
|
||||
val i1 = Identifier("name", false, true)
|
||||
val i2 = Identifier("name", false)
|
||||
val i3 = Identifier("name")
|
||||
}
|
||||
public object User {
|
||||
public fun main(args: Array<String>) {
|
||||
val i1 = Identifier("name", false, true)
|
||||
val i2 = Identifier("name", false)
|
||||
val i3 = Identifier("name")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,23 +4,21 @@
|
||||
// ERROR: Unresolved reference: close
|
||||
import java.io.*
|
||||
|
||||
class FileRead {
|
||||
companion object {
|
||||
public fun main(args: Array<String>) {
|
||||
try {
|
||||
val fstream = FileInputStream()
|
||||
val `in` = DataInputStream(fstream)
|
||||
val br = BufferedReader(InputStreamReader(`in`))
|
||||
val strLine: String
|
||||
while ((strLine = br.readLine()) != null) {
|
||||
System.out.println(strLine)
|
||||
}
|
||||
`in`.close()
|
||||
} catch (e: Exception) {
|
||||
System.err.println("Error: " + e.getMessage())
|
||||
object FileRead {
|
||||
public fun main(args: Array<String>) {
|
||||
try {
|
||||
val fstream = FileInputStream()
|
||||
val `in` = DataInputStream(fstream)
|
||||
val br = BufferedReader(InputStreamReader(`in`))
|
||||
val strLine: String
|
||||
while ((strLine = br.readLine()) != null) {
|
||||
System.out.println(strLine)
|
||||
}
|
||||
|
||||
`in`.close()
|
||||
} catch (e: Exception) {
|
||||
System.err.println("Error: " + e.getMessage())
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,10 +4,8 @@ class Container {
|
||||
var myString = "1"
|
||||
}
|
||||
|
||||
class One {
|
||||
companion object {
|
||||
var myContainer = Container()
|
||||
}
|
||||
object One {
|
||||
var myContainer = Container()
|
||||
}
|
||||
|
||||
class StringContainer(s: String)
|
||||
|
||||
@@ -4,10 +4,8 @@ class Container {
|
||||
var myInt = 1
|
||||
}
|
||||
|
||||
class One {
|
||||
companion object {
|
||||
var myContainer = Container()
|
||||
}
|
||||
object One {
|
||||
var myContainer = Container()
|
||||
}
|
||||
|
||||
class IntContainer(i: Int)
|
||||
|
||||
@@ -4,10 +4,8 @@ class Container {
|
||||
var myInt = 1
|
||||
}
|
||||
|
||||
class One {
|
||||
companion object {
|
||||
var myContainer = Container()
|
||||
}
|
||||
object One {
|
||||
var myContainer = Container()
|
||||
}
|
||||
|
||||
class Test {
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
class Test {
|
||||
companion object {
|
||||
public fun toFileSystemSafeName(name: String): String {
|
||||
val size = name.length()
|
||||
return name
|
||||
}
|
||||
object Test {
|
||||
public fun toFileSystemSafeName(name: String): String {
|
||||
val size = name.length()
|
||||
return name
|
||||
}
|
||||
}
|
||||
@@ -4,10 +4,8 @@ class Container {
|
||||
var myInt = 1
|
||||
}
|
||||
|
||||
class One {
|
||||
companion object {
|
||||
var myContainer = Container()
|
||||
}
|
||||
object One {
|
||||
var myContainer = Container()
|
||||
}
|
||||
|
||||
class Test {
|
||||
|
||||
@@ -5,17 +5,15 @@ import java.io.File
|
||||
/**
|
||||
* User: ignatov
|
||||
*/
|
||||
public class Test {
|
||||
companion object {
|
||||
public fun isDir(parent: File?): Boolean {
|
||||
if (parent == null || !parent.exists()) {
|
||||
return false
|
||||
}
|
||||
val result = true
|
||||
if (parent.isDirectory()) {
|
||||
return true
|
||||
} else
|
||||
return false
|
||||
public object Test {
|
||||
public fun isDir(parent: File?): Boolean {
|
||||
if (parent == null || !parent.exists()) {
|
||||
return false
|
||||
}
|
||||
val result = true
|
||||
if (parent.isDirectory()) {
|
||||
return true
|
||||
} else
|
||||
return false
|
||||
}
|
||||
}
|
||||
@@ -4,10 +4,8 @@ class Container {
|
||||
var myBoolean = true
|
||||
}
|
||||
|
||||
class One {
|
||||
companion object {
|
||||
var myContainer = Container()
|
||||
}
|
||||
object One {
|
||||
var myContainer = Container()
|
||||
}
|
||||
|
||||
class Test {
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
package demo
|
||||
|
||||
class Program {
|
||||
companion object {
|
||||
public fun main(args: Array<String>) {
|
||||
System.out.println("Halo!")
|
||||
}
|
||||
object Program {
|
||||
public fun main(args: Array<String>) {
|
||||
System.out.println("Halo!")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
class Test {
|
||||
companion object {
|
||||
public fun getInt(i: Int): Int {
|
||||
when (i) {
|
||||
0 -> return 0
|
||||
1 -> return 1
|
||||
2 -> return 2
|
||||
3 -> return 3
|
||||
else -> return -1
|
||||
}
|
||||
object Test {
|
||||
public fun getInt(i: Int): Int {
|
||||
when (i) {
|
||||
0 -> return 0
|
||||
1 -> return 1
|
||||
2 -> return 2
|
||||
3 -> return 3
|
||||
else -> return -1
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user