Java to Kotlin converter tests: added check for errors in result file

This commit is contained in:
Valentin Kipyatkov
2014-10-24 12:54:28 +04:00
committed by valentin
parent 389b14f44f
commit 82fc0ee394
122 changed files with 266 additions and 77 deletions
@@ -32,6 +32,10 @@ import org.jetbrains.jet.plugin.JetWithJdkAndRuntimeLightProjectDescriptor
import com.intellij.psi.PsiJavaFile import com.intellij.psi.PsiJavaFile
import org.jetbrains.jet.j2k.IdeaReferenceSearcher import org.jetbrains.jet.j2k.IdeaReferenceSearcher
import org.jetbrains.jet.j2k.JavaToKotlinConverter import org.jetbrains.jet.j2k.JavaToKotlinConverter
import org.jetbrains.jet.lang.psi.JetFile
import org.jetbrains.jet.plugin.caches.resolve.getAnalysisResults
import org.jetbrains.jet.lang.diagnostics.Severity
import org.jetbrains.jet.lang.diagnostics.rendering.DefaultErrorMessages
public abstract class AbstractJavaToKotlinConverterSingleFileTest() : AbstractJavaToKotlinConverterTest() { public abstract class AbstractJavaToKotlinConverterSingleFileTest() : AbstractJavaToKotlinConverterTest() {
val testHeaderPattern = Pattern.compile("//(element|expression|statement|method|class|file|comp)\n") val testHeaderPattern = Pattern.compile("//(element|expression|statement|method|class|file|comp)\n")
@@ -80,8 +84,18 @@ public abstract class AbstractJavaToKotlinConverterSingleFileTest() : AbstractJa
val reformatInFun = prefix in setOf("element", "expression", "statement") val reformatInFun = prefix in setOf("element", "expression", "statement")
val actual = reformat(rawConverted, project, reformatInFun) var actual = reformat(rawConverted, project, reformatInFun)
val kotlinPath = javaPath.replace(".java", ".kt") val kotlinPath = javaPath.replace(".java", ".kt")
if (prefix == "file") {
val diagnostics = createKotlinFile(actual).getAnalysisResults().getBindingContext().getDiagnostics()
val errors = diagnostics.filter { it.getSeverity() == Severity.ERROR }
if (!errors.isEmpty()) {
val header = errors.map { "// ERROR: " + DefaultErrorMessages.RENDERER.render(it).replace('\n', ' ') }.joinToString("\n", postfix = "\n")
actual = header + actual
}
}
val expectedFile = File(kotlinPath) val expectedFile = File(kotlinPath)
JetTestUtils.assertEqualsToFile(expectedFile, actual) JetTestUtils.assertEqualsToFile(expectedFile, actual)
} }
@@ -146,4 +160,8 @@ public abstract class AbstractJavaToKotlinConverterSingleFileTest() : AbstractJa
private fun createJavaFile(text: String): PsiJavaFile { private fun createJavaFile(text: String): PsiJavaFile {
return myFixture.configureByText("converterTestFile.java", text) as PsiJavaFile return myFixture.configureByText("converterTestFile.java", text) as PsiJavaFile
} }
private fun createKotlinFile(text: String): JetFile {
return myFixture.configureByText("converterTestFile.kt", text) as JetFile
}
} }
+1 -1
View File
@@ -59,6 +59,6 @@ public class WithVarargConstructor {
public WithVarargConstructor(int p, Object... objects) { } public WithVarargConstructor(int p, Object... objects) { }
} }
class T { public class T {
public Set<String> set; public Set<String> set;
} }
@@ -1,3 +1,4 @@
// ERROR: Body is not allowed for annotation class
annotation class Anon(public val value: String) { annotation class Anon(public val value: String) {
public enum class E { public enum class E {
@@ -1,5 +1,5 @@
class Test { class Test {
String str; static String str;
static { static {
str = "Ola"; str = "Ola";
} }
@@ -1,7 +1,6 @@
class Test { class Test {
var str: String
class object { class object {
var str: String
{ {
str = "Ola" str = "Ola"
} }
@@ -1,10 +1,10 @@
// !forceNotNullTypes: false // !forceNotNullTypes: false
// !specifyLocalVariableTypeByDefault: true // !specifyLocalVariableTypeByDefault: true
import java.util.BitSet; import java.util.HashSet;
class Foo { class Foo {
void foo(BitSet o) { void foo(HashSet o) {
BitSet o2 = o; HashSet o2 = o;
int foo = 0; int foo = 0;
foo = o2.size(); foo = o2.size();
} }
@@ -1,10 +1,10 @@
// !forceNotNullTypes: false // !forceNotNullTypes: false
// !specifyLocalVariableTypeByDefault: true // !specifyLocalVariableTypeByDefault: true
import java.util.BitSet import java.util.HashSet
class Foo { class Foo {
fun foo(o: BitSet?) { fun foo(o: HashSet<Any?>?) {
val o2: BitSet? = o val o2: HashSet<Any?>? = o
var foo: Int = 0 var foo: Int = 0
foo = o2!!.size() foo = o2!!.size()
} }
@@ -1,8 +1,8 @@
import java.util.BitSet; import java.util.HashSet;
class Foo { class Foo {
void foo(BitSet o) { void foo(HashSet o) {
BitSet o2 = o; HashSet o2 = o;
int foo = 0; int foo = 0;
foo = o2.size(); foo = o2.size();
} }
@@ -1,7 +1,7 @@
import java.util.BitSet import java.util.HashSet
class Foo { class Foo {
fun foo(o: BitSet) { fun foo(o: HashSet<Any>) {
val o2 = o val o2 = o
var foo = 0 var foo = 0
foo = o2.size() foo = o2.size()
@@ -1,3 +1,4 @@
// ERROR: None of the following functions can be called with the arguments supplied: public open fun valueOf(p0: kotlin.String!, p1: kotlin.Int): kotlin.Short! defined in java.lang.Short public open fun valueOf(p0: kotlin.String!): kotlin.Short! defined in java.lang.Short public open fun valueOf(p0: kotlin.Short): kotlin.Short! defined in java.lang.Short
package demo package demo
class Test { class Test {
@@ -4,6 +4,6 @@ class Library {
class User { class User {
void main() { void main() {
Library.ourOut.print(); Library.ourOut.print(1);
} }
} }
@@ -1,3 +1,4 @@
// ERROR: Property must be initialized or be abstract
class Library { class Library {
class object { class object {
val ourOut: java.io.PrintStream val ourOut: java.io.PrintStream
@@ -6,6 +7,6 @@ class Library {
class User { class User {
fun main() { fun main() {
Library.ourOut.print() Library.ourOut.print(1)
} }
} }
@@ -4,6 +4,6 @@ class Library {
class User { class User {
void main() { void main() {
Library.myString.isEmpty(); new Library().myString.isEmpty();
} }
} }
@@ -1,9 +1,10 @@
// ERROR: Property must be initialized or be abstract
class Library { class Library {
public val myString: String public val myString: String
} }
class User { class User {
fun main() { fun main() {
Library.myString.isEmpty() Library().myString.isEmpty()
} }
} }
@@ -1,3 +1,10 @@
// ERROR: 'internal fun Test(): demo.Test' is already defined in demo
// ERROR: 'public constructor Test()' is already defined in demo
// ERROR: Overload resolution ambiguity: internal fun Test(): demo.Test defined in demo public constructor Test() defined in demo.Test
// ERROR: Overload resolution ambiguity: internal fun Test(): demo.Test defined in demo public constructor Test() defined in demo.Test
// ERROR: Type inference failed: Not enough information to infer parameter K in constructor HashMap<K, V>(p0: kotlin.Int) Please specify it explicitly.
// ERROR: Type inference failed: Not enough information to infer parameter K in constructor HashMap<K, V>(p0: kotlin.Int) Please specify it explicitly.
// ERROR: Overload resolution ambiguity: internal fun Test(): demo.Test defined in demo public constructor Test() defined in demo.Test
package demo package demo
import java.util.HashMap import java.util.HashMap
@@ -1,3 +1,4 @@
// ERROR: Class 'A' must be declared abstract or implement abstract member public abstract fun run(): kotlin.Unit defined in java.lang.Runnable
package foo package foo
// we use package 'foo' // we use package 'foo'
@@ -11,9 +11,9 @@ class A {
private/*it's private*/ int field = 0; private/*it's private*/ int field = 0;
public /*it's public*/ char foo() { } public /*it's public*/ char foo(String s) { }
protected/*it's protected*/ void foo() { } protected/*it's protected*/ void foo(char c) { }
public/*it's public*/ static/*and static*/ final/*and final*/ int C = 1; public/*it's public*/ static/*and static*/ final/*and final*/ int C = 1;
} }
@@ -1,3 +1,5 @@
// ERROR: A 'return' expression required in a function with a block body ('{...}')
// ERROR: A 'return' expression required in a function with a block body ('{...}')
package foo package foo
class A { class A {
@@ -13,10 +15,10 @@ class A {
private /*it's private*/ val field = 0 private /*it's private*/ val field = 0
public /*it's public*/ fun foo(): Char { public /*it's public*/ fun foo(s: String): Char {
} }
protected /*it's protected*/ fun foo() { protected /*it's protected*/ fun foo(c: Char) {
} }
class object { class object {
@@ -1,3 +1,7 @@
// ERROR: 'public fun Test(s: kotlin.String): Test' is already defined in root package
// ERROR: 'public constructor Test(s: kotlin.String)' is already defined in root package
// ERROR: None of the following functions can be called with the arguments supplied: public fun Test(): Test defined in root package public fun Test(s: kotlin.String): Test defined in root package public constructor Test(s: kotlin.String) defined in Test
// ERROR: Overload resolution ambiguity: public fun Test(s: kotlin.String): Test defined in root package public constructor Test(s: kotlin.String) defined in Test
public fun Test(): Test { public fun Test(): Test {
val __ = Test(null) val __ = Test(null)
__.b = true __.b = true
@@ -1,3 +1,4 @@
// ERROR: Property must be initialized or be abstract
class C(x: Any, b: Boolean) { class C(x: Any, b: Boolean) {
public var x: Any public var x: Any
@@ -1,3 +1,4 @@
// ERROR: This type is final, so it cannot be inherited from
class Base(o: Any, l: Int) class Base(o: Any, l: Int)
class C(private val string: String) : Base(string, string.length()) class C(private val string: String) : Base(string, string.length())
@@ -1,3 +1,9 @@
// ERROR: 'public fun <T> Identifier(name: T, isNullable: kotlin.Boolean): Identifier<T>' is already defined in root package
// ERROR: 'public constructor Identifier<T>(name: T, myHasDollar: kotlin.Boolean)' is already defined in root package
// ERROR: Cannot choose among the following candidates without completing type inference: public fun <T> Identifier(name: T, isNullable: kotlin.Boolean): Identifier<T> defined in root package public constructor Identifier<T>(name: T, myHasDollar: kotlin.Boolean) defined in Identifier
// ERROR: Cannot choose among the following candidates without completing type inference: public fun <T> Identifier(name: T, isNullable: kotlin.Boolean): Identifier<T> defined in root package public constructor Identifier<T>(name: T, myHasDollar: kotlin.Boolean) defined in Identifier
// ERROR: Cannot choose among the following candidates without completing type inference: public fun <T> Identifier(name: T, isNullable: kotlin.Boolean): Identifier<T> defined in root package public constructor Identifier<T>(name: T, myHasDollar: kotlin.Boolean) defined in Identifier
// ERROR: Overload resolution ambiguity: public fun <T> Identifier(name: kotlin.String, isNullable: kotlin.Boolean): Identifier<kotlin.String> defined in root package public constructor Identifier<T>(name: kotlin.String, myHasDollar: kotlin.Boolean) defined in Identifier
public fun <T> Identifier(name: T): Identifier<T> { public fun <T> Identifier(name: T): Identifier<T> {
return Identifier(name, false) return Identifier(name, false)
} }
@@ -1,3 +1,9 @@
// ERROR: 'public fun Identifier(name: kotlin.String, isNullable: kotlin.Boolean): Identifier' is already defined in root package
// ERROR: 'public constructor Identifier(name: kotlin.String, myHasDollar: kotlin.Boolean)' is already defined in root package
// ERROR: Overload resolution ambiguity: public fun Identifier(name: kotlin.String, isNullable: kotlin.Boolean): Identifier defined in root package public constructor Identifier(name: kotlin.String, myHasDollar: kotlin.Boolean) defined in Identifier
// ERROR: Overload resolution ambiguity: public fun Identifier(name: kotlin.String, isNullable: kotlin.Boolean): Identifier defined in root package public constructor Identifier(name: kotlin.String, myHasDollar: kotlin.Boolean) defined in Identifier
// ERROR: Overload resolution ambiguity: public fun Identifier(name: kotlin.String, isNullable: kotlin.Boolean): Identifier defined in root package public constructor Identifier(name: kotlin.String, myHasDollar: kotlin.Boolean) defined in Identifier
// ERROR: Overload resolution ambiguity: public fun Identifier(name: kotlin.String, isNullable: kotlin.Boolean): Identifier defined in root package public constructor Identifier(name: kotlin.String, myHasDollar: kotlin.Boolean) defined in Identifier
public fun Identifier(name: String): Identifier { public fun Identifier(name: String): Identifier {
return Identifier(name, false) return Identifier(name, false)
} }
@@ -5,6 +5,7 @@ class C {
int foo(int p){ return p; } int foo(int p){ return p; }
private static int staticFoo(int p){ return p; } private static int staticFoo(int p){ return p; }
public static int staticFoo2(){ return 0; }
C(int arg1, int arg2, int arg3) { C(int arg1, int arg2, int arg3) {
this.arg1 = arg1; this.arg1 = arg1;
@@ -1,3 +1,5 @@
// ERROR: Cannot access 'staticFoo': it is 'private' in '<class-object-for-C>'
// ERROR: Cannot access 'staticFoo': it is 'private' in '<class-object-for-C>'
fun C(arg1: Int, arg2: Int, other: C): C { fun C(arg1: Int, arg2: Int, other: C): C {
val __ = C(arg1, arg2, 0) val __ = C(arg1, arg2, 0)
System.out.println(__.foo(1) + __.foo(2) + other.foo(3) + C.staticFoo(4) + C.staticFoo(5)) System.out.println(__.foo(1) + __.foo(2) + other.foo(3) + C.staticFoo(4) + C.staticFoo(5))
@@ -10,7 +12,13 @@ class C(private val arg1: Int, private val arg2: Int, private val arg3: Int) {
return p return p
} }
private fun staticFoo(p: Int): Int { class object {
return p private fun staticFoo(p: Int): Int {
return p
}
public fun staticFoo2(): Int {
return 0
}
} }
} }
@@ -1,3 +1,4 @@
// ERROR: Property must be initialized or be abstract
import A.Nested import A.Nested
class A(nested: Nested = Nested(Nested.FIELD)) { class A(nested: Nested = Nested(Nested.FIELD)) {
@@ -1,3 +1,4 @@
// ERROR: Property must be initialized or be abstract
package pack package pack
import pack.A.Nested import pack.A.Nested
@@ -1,3 +1,4 @@
// ERROR: Property must be initialized or be abstract
package pack package pack
import pack.A.* import pack.A.*
@@ -1,3 +1,4 @@
// ERROR: This type is final, so it cannot be inherited from
class Base(nested: Base.Nested) { class Base(nested: Base.Nested) {
class Nested(p: Int) { class Nested(p: Int) {
@@ -1,3 +1,4 @@
// ERROR: Overload resolution ambiguity: internal fun C(arg1: kotlin.Int, arg2: kotlin.Int): C defined in root package public constructor C(arg1: kotlin.Int, arg2: kotlin.Int = ..., arg3: kotlin.Int = ...) defined in C
fun C(arg1: Int, arg2: Int): C { fun C(arg1: Int, arg2: Int): C {
var arg2 = arg2 var arg2 = arg2
val __ = C(arg1, arg2, 0) val __ = C(arg1, arg2, 0)
@@ -1,3 +1,5 @@
// ERROR: Too many arguments for internal fun C(arg1: kotlin.Int): C defined in root package
// ERROR: Too many arguments for internal fun C(arg1: kotlin.Int): C defined in root package
fun C(arg1: Int): C { fun C(arg1: Int): C {
return C(arg1, 0, 0) return C(arg1, 0, 0)
} }
@@ -1,3 +1,5 @@
// ERROR: Cannot access 'arg1': it is 'private' in 'C'
// ERROR: Cannot access 'arg2': it is 'private' in 'C'
fun C(arg1: Int, arg2: Int, other: C): C { fun C(arg1: Int, arg2: Int, other: C): C {
val __ = C(arg1, arg2, 0) val __ = C(arg1, arg2, 0)
System.out.println(__.arg1 + other.arg2) System.out.println(__.arg1 + other.arg2)
@@ -1,3 +1,5 @@
// ERROR: Cannot access 'staticField1': it is 'private' in '<class-object-for-C>'
// ERROR: Cannot access 'staticField2': it is 'private' in '<class-object-for-C>'
fun C(p: Int): C { fun C(p: Int): C {
val __ = C() val __ = C()
System.out.println(C.staticField1 + C.staticField2) System.out.println(C.staticField1 + C.staticField2)
@@ -1,3 +1,8 @@
// ERROR: 'public fun Test(name: kotlin.String): Test' is already defined in root package
// ERROR: 'public constructor Test(myName: kotlin.String)' is already defined in root package
// ERROR: None of the following functions can be called with the arguments supplied: public fun Test(): Test defined in root package public fun Test(name: kotlin.String): Test defined in root package public constructor Test(myName: kotlin.String) defined in Test
// ERROR: Overload resolution ambiguity: public fun Test(name: kotlin.String): Test defined in root package public constructor Test(myName: kotlin.String) defined in Test
// ERROR: Overload resolution ambiguity: public fun Test(name: kotlin.String): Test defined in root package public constructor Test(myName: kotlin.String) defined in Test
public fun Test(): Test { public fun Test(): Test {
return Test(null) return Test(null)
} }
@@ -1,3 +1,4 @@
// ERROR: This type is final, so it cannot be inherited from
public class Base(x: Int) { public class Base(x: Int) {
public var x: Int = 42 public var x: Int = 42
protected set protected set
@@ -1,3 +1,4 @@
// ERROR: This type is final, so it cannot be inherited from
public class AAA { public class AAA {
public var x: Int = 42 public var x: Int = 42
protected set protected set
@@ -1,3 +1,4 @@
// ERROR: Type mismatch: inferred type is kotlin.String? but kotlin.Any was expected
class A { class A {
private val s: String? = null private val s: String? = null
@@ -1,3 +1,4 @@
// ERROR: This type is final, so it cannot be inherited from
class Base { class Base {
private val myFirst: String? = null private val myFirst: String? = null
} }
@@ -1,3 +1,5 @@
// ERROR: Unresolved reference: Foo
// ERROR: Property must be initialized or be abstract
class C { class C {
var f: Foo var f: Foo
} }
@@ -1,3 +1,4 @@
// ERROR: Unresolved reference: Foo
class C { class C {
private val f: Foo? = null private val f: Foo? = null
} }
@@ -1,3 +1,5 @@
// ERROR: Unresolved reference: Foo
// ERROR: Property must be initialized or be abstract
class C { class C {
protected var f: Foo protected var f: Foo
} }
@@ -1,3 +1,5 @@
// ERROR: Unresolved reference: Foo
// ERROR: Property must be initialized or be abstract
class C { class C {
public var f: Foo public var f: Foo
} }
@@ -1,3 +1,4 @@
// ERROR: Unresolved reference: Foo
class C { class C {
val f = Foo(1, 2) val f = Foo(1, 2)
} }
@@ -1,3 +1,4 @@
// ERROR: Unresolved reference: Foo
class C { class C {
var f = Foo(1, 2) var f = Foo(1, 2)
} }
@@ -1,3 +1,5 @@
// ERROR: Unresolved reference: Foo
// ERROR: Property must be initialized or be abstract
class C { class C {
var f: Foo var f: Foo
} }
@@ -1,3 +1,4 @@
// ERROR: An integer literal does not conform to the expected type kotlin.Double
class A { class A {
deprecated("") deprecated("")
volatile var field1 = 0 volatile var field1 = 0
@@ -1,3 +1,8 @@
// ERROR: 'clone' in 'Base' is final and cannot be overridden
// ERROR: 'finalize' in 'Base' is final and cannot be overridden
// ERROR: This type is final, so it cannot be inherited from
// ERROR: Unresolved reference: clone
// ERROR: Unresolved reference: finalize
package test package test
class Test : Base() { class Test : Base() {
@@ -1,3 +1,5 @@
// ERROR: 'a' in 'A' is final and cannot be overridden
// ERROR: This type is final, so it cannot be inherited from
class A { class A {
fun a() { fun a() {
} }
@@ -1,3 +1,6 @@
// ERROR: 'foo' in 'A' is final and cannot be overridden
// ERROR: This type is final, so it cannot be inherited from
// ERROR: This type is final, so it cannot be inherited from
class A { class A {
fun foo() { fun foo() {
} }
@@ -1,3 +1,4 @@
// ERROR: Unresolved reference: clone
class X { class X {
override fun hashCode(): Int { override fun hashCode(): Int {
return super.hashCode() return super.hashCode()
@@ -1,3 +1,5 @@
// ERROR: This type is final, so it cannot be inherited from
// ERROR: Unresolved reference: clone
class Base class Base
class X : Base() { class X : Base() {
@@ -1,3 +1,4 @@
// ERROR: This type is final, so it cannot be inherited from
class Base { class Base {
override fun equals(o: Any?): Boolean { override fun equals(o: Any?): Boolean {
return super.equals(o) return super.equals(o)
@@ -1,3 +1,4 @@
// ERROR: This type is final, so it cannot be inherited from
class `$$$$$` class `$$$$$`
class `$` class `$`
@@ -1,3 +1,4 @@
// ERROR: Unresolved reference: `as`
package test package test
import `as`.`type`.`val`.`var`.`fun`.`is`.`in`.`object`.`when`.`trait`.`This` import `as`.`type`.`val`.`var`.`fun`.`is`.`in`.`object`.`when`.`trait`.`This`
@@ -1,2 +1,3 @@
// ERROR: Unresolved reference: ArrayBlockingQueue
import java.util.Arrays import java.util.Arrays
import java.util.concurrent.ArrayBlockingQueue import java.util.concurrent.ArrayBlockingQueue
@@ -1,3 +1,4 @@
// ERROR: This type is final, so it cannot be inherited from
class Base<T>(name: T) class Base<T>(name: T)
class One<T, K>(name: T, private val mySecond: K) : Base<T>(name) class One<T, K>(name: T, private val mySecond: K) : Base<T>(name)
@@ -1,3 +1,4 @@
// ERROR: This type is final, so it cannot be inherited from
class Base(name: String) class Base(name: String)
class One(name: String, second: String) : Base(name) class One(name: String, second: String) : Base(name)
@@ -1,3 +1,4 @@
// ERROR: This type is final, so it cannot be inherited from
class Base class Base
class One : Base() class One : Base()
@@ -1,3 +1,4 @@
// ERROR: This type is final, so it cannot be inherited from
class Base(name: String) class Base(name: String)
class One(name: String, private val mySecond: String) : Base(name) class One(name: String, private val mySecond: String) : Base(name)
@@ -1,3 +1,5 @@
// ERROR: Type inference failed: Not enough information to infer parameter K in constructor HashMap<K, V>() Please specify it explicitly.
// ERROR: Type inference failed: Not enough information to infer parameter K in constructor HashMap<K, V>() Please specify it explicitly.
import java.util.HashMap import java.util.HashMap
class G<T : String>(t: T) class G<T : String>(t: T)
@@ -1,3 +1,5 @@
// ERROR: This type is final, so it cannot be inherited from
// ERROR: Property must be initialized or be abstract
class Base { class Base {
inner class Nested inner class Nested
} }
@@ -1,3 +1,9 @@
// ERROR: 'public fun <T> Identifier(name: T, isNullable: kotlin.Boolean): Identifier<T>' is already defined in root package
// ERROR: 'public constructor Identifier<T>(name: T, myHasDollar: kotlin.Boolean)' is already defined in root package
// ERROR: Cannot choose among the following candidates without completing type inference: public fun <T> Identifier(name: T, isNullable: kotlin.Boolean): Identifier<T> defined in root package public constructor Identifier<T>(name: T, myHasDollar: kotlin.Boolean) defined in Identifier
// ERROR: Cannot choose among the following candidates without completing type inference: public fun <T> Identifier(name: T, isNullable: kotlin.Boolean): Identifier<T> defined in root package public constructor Identifier<T>(name: T, myHasDollar: kotlin.Boolean) defined in Identifier
// ERROR: Cannot choose among the following candidates without completing type inference: public fun <T> Identifier(name: T, isNullable: kotlin.Boolean): Identifier<T> defined in root package public constructor Identifier<T>(name: T, myHasDollar: kotlin.Boolean) defined in Identifier
// ERROR: Overload resolution ambiguity: public fun <T> Identifier(name: kotlin.String, isNullable: kotlin.Boolean): Identifier<kotlin.String> defined in root package public constructor Identifier<T>(name: kotlin.String, myHasDollar: kotlin.Boolean) defined in Identifier
public fun <T> Identifier(name: T): Identifier<T> { public fun <T> Identifier(name: T): Identifier<T> {
return Identifier(name, false) return Identifier(name, false)
} }
@@ -1,3 +1,4 @@
// ERROR: This type is final, so it cannot be inherited from
package test package test
class Base { class Base {
@@ -3,7 +3,7 @@ import java.io.*;
class FileRead { class FileRead {
public static void main(String args[]) { public static void main(String args[]) {
try { try {
FileInputStream fstream = new FileInputStream("textfile.txt"); FileInputStream fstream = new FileInputStream();
DataInputStream in = new DataInputStream(fstream); DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in)); BufferedReader br = new BufferedReader(new InputStreamReader(in));
String strLine; String strLine;
@@ -1,10 +1,14 @@
// ERROR: None of the following functions can be called with the arguments supplied: public constructor FileInputStream(p0: kotlin.String!) defined in java.io.FileInputStream public constructor FileInputStream(p0: java.io.File!) defined in java.io.FileInputStream public constructor FileInputStream(p0: [ERROR : Unresolved java classifier: FileDescriptor]!) defined in java.io.FileInputStream
// ERROR: None of the following functions can be called with the arguments supplied: public constructor InputStreamReader(p0: java.io.InputStream!) defined in java.io.InputStreamReader public constructor InputStreamReader(p0: java.io.InputStream!, p1: kotlin.String!) defined in java.io.InputStreamReader public constructor InputStreamReader(p0: java.io.InputStream!, p1: java.nio.charset.Charset!) defined in java.io.InputStreamReader public constructor InputStreamReader(p0: java.io.InputStream!, p1: [ERROR : Unresolved java classifier: CharsetDecoder]!) defined in java.io.InputStreamReader
// ERROR: Assignments are not expressions, and only expressions are allowed in this context
// ERROR: Unresolved reference: close
import java.io.* import java.io.*
class FileRead { class FileRead {
class object { class object {
public fun main(args: Array<String>) { public fun main(args: Array<String>) {
try { try {
val fstream = FileInputStream("textfile.txt") val fstream = FileInputStream()
val `in` = DataInputStream(fstream) val `in` = DataInputStream(fstream)
val br = BufferedReader(InputStreamReader(`in`)) val br = BufferedReader(InputStreamReader(`in`))
val strLine: String val strLine: String
@@ -1,3 +1,5 @@
// ERROR: 'test' in 'Base' is final and cannot be overridden
// ERROR: This type is final, so it cannot be inherited from
package com.voltvoodoo.saplo4j.model package com.voltvoodoo.saplo4j.model
import java.io.Serializable import java.io.Serializable
@@ -1,3 +1,4 @@
// ERROR: Variable cannot be initialized before declaration
package demo package demo
class C(a: Int) { class C(a: Int) {
@@ -1,3 +1,4 @@
// ERROR: No value passed for parameter field
import kotlinApi.* import kotlinApi.*
class C : KotlinClass() { class C : KotlinClass() {
@@ -1,3 +1,4 @@
// ERROR: Unresolved reference: LinkedList
import java.util.* import java.util.*
public class ForEach { public class ForEach {
@@ -1,3 +1,4 @@
// ERROR: Unresolved reference: LinkedList
import java.util.* import java.util.*
public class Lists { public class Lists {
@@ -1,3 +1,5 @@
// ERROR: Too many arguments for public fun <T> listOf(): kotlin.List<T> defined in kotlin
// ERROR: Null can not be a value of a non-null type kotlin.String
import java.util.* import java.util.*
class A { class A {
@@ -1,3 +1,5 @@
// ERROR: Unresolved reference: ast2
// ERROR: Unresolved reference: ast
package test package test
import ast import ast
@@ -1,3 +1,5 @@
// ERROR: Unresolved reference: ast2
// ERROR: Unresolved reference: ast
package test package test
import ast import ast
@@ -1,3 +1,5 @@
// ERROR: Unresolved reference: ast2
// ERROR: Unresolved reference: ast
package test package test
import ast import ast
@@ -1,3 +1,4 @@
// ERROR: Type mismatch: inferred type is T? but T was expected
import java.util.* import java.util.*
import kotlin.Collection import kotlin.Collection
@@ -5,6 +5,6 @@ import java.util.List;
class User { class User {
void main() { void main() {
List list = new java.util.LinkedList(); List list = new java.util.ArrayList();
} }
} }
@@ -1,7 +1,8 @@
// ERROR: Type inference failed: Not enough information to infer parameter E in constructor ArrayList<E>() Please specify it explicitly.
package test package test
class User { class User {
fun main() { fun main() {
val list = java.util.LinkedList() val list = java.util.ArrayList()
} }
} }
@@ -3,6 +3,6 @@ package test;
class User { class User {
void main() { void main() {
java.util.List list = new java.util.LinkedList(); java.util.List list = new java.util.ArrayList();
} }
} }
@@ -1,7 +1,8 @@
// ERROR: Type inference failed: Not enough information to infer parameter E in constructor ArrayList<E>() Please specify it explicitly.
package test package test
class User { class User {
fun main() { fun main() {
val list = java.util.LinkedList() val list = java.util.ArrayList()
} }
} }
@@ -1,9 +1,9 @@
//file //file
import java.util.List; import java.util.List;
import java.util.LinkedList; import java.util.ArrayList;
class User { class User {
void main() { void main() {
List<String> list = new LinkedList<String>(); List<String> list = new ArrayList<String>();
} }
} }
@@ -1,7 +1,7 @@
import java.util.LinkedList import java.util.ArrayList
class User { class User {
fun main() { fun main() {
val list = LinkedList<String>() val list = ArrayList<String>()
} }
} }
@@ -2,13 +2,13 @@
package org.test; package org.test;
import java.util.List; import java.util.List;
import java.util.LinkedList; import java.util.ArrayList;
class Member {} class Member {}
class User { class User {
void main() { void main() {
List<Member> members = new LinkedList<Member>(); List<Member> members = new ArrayList<Member>();
members.add(new Member()); members.add(new Member());
} }
} }
@@ -1,12 +1,12 @@
package org.test package org.test
import java.util.LinkedList import java.util.ArrayList
class Member class Member
class User { class User {
fun main() { fun main() {
val members = LinkedList<Member>() val members = ArrayList<Member>()
members.add(Member()) members.add(Member())
} }
} }
@@ -1,3 +1,4 @@
// ERROR: Unresolved reference: x
class C { class C {
private val s = x() private val s = x()
@@ -1,3 +1,4 @@
// ERROR: Unresolved reference: x
class C { class C {
private val string = getString() private val string = getString()
@@ -1,3 +1,4 @@
// ERROR: Return type of 'get' is not a subtype of the return type of overridden member public abstract fun get(): kotlin.String defined in Getter
trait Getter { trait Getter {
public fun get(): String public fun get(): String
} }
@@ -1,3 +1,7 @@
// ERROR: There's a cycle in the inheritance hierarchy for this type
// ERROR: There's a cycle in the inheritance hierarchy for this type
// ERROR: This type is final, so it cannot be inherited from
// ERROR: This type is final, so it cannot be inherited from
class A : B() { class A : B() {
public fun foo(s: String) { public fun foo(s: String) {
} }
@@ -1,3 +1,6 @@
// ERROR: 'foo' in 'Base' is final and cannot be overridden
// ERROR: 'bar' in 'Base' is final and cannot be overridden
// ERROR: This type is final, so it cannot be inherited from
class Base { class Base {
public fun foo(s: String?): String? { public fun foo(s: String?): String? {
return "" return ""
@@ -1,18 +1,26 @@
//file //file
package demo; package demo;
class WindowAdapter { interface WindowListener {
void windowClosing ();
}
class WindowAdapter implements WindowListener {
public void windowClosing () { public void windowClosing () {
} }
} }
class Frame {
public void addWindowListener(WindowListener listener){}
}
public final class Client extends Frame { public final class Client extends Frame {
Client() { Client() {
WindowAdapter a = new WindowAdapter() { WindowAdapter a = new WindowAdapter() {
@Override @Override
public void windowClosing () { public void windowClosing () {
} }
} };
addWindowListener(a); addWindowListener(a);
@@ -1,7 +1,19 @@
// ERROR: This type is final, so it cannot be inherited from
// ERROR: This type is final, so it cannot be inherited from
// ERROR: This type is final, so it cannot be inherited from
package demo package demo
class WindowAdapter { trait WindowListener {
public fun windowClosing() { public fun windowClosing()
}
class WindowAdapter : WindowListener {
override fun windowClosing() {
}
}
class Frame {
public fun addWindowListener(listener: WindowListener) {
} }
} }
@@ -1,3 +1,4 @@
// ERROR: Type inference failed: Not enough information to infer parameter K in constructor HashMap<K, V>() Please specify it explicitly.
package demo package demo
import java.util.HashMap import java.util.HashMap
@@ -2,12 +2,12 @@
package demo; package demo;
import java.util.List; import java.util.List;
import java.util.LinkedList; import java.util.ArrayList;
class Test { class Test {
void main() { void main() {
List<String> common = new LinkedList<String>(); List<String> common = new ArrayList<String>();
List raw = new LinkedList<String>(); List raw = new ArrayList<String>();
List superRaw = new LinkedList(); List superRaw = new ArrayList();
} }
} }
@@ -1,11 +1,12 @@
// ERROR: Type inference failed: Not enough information to infer parameter E in constructor ArrayList<E>() Please specify it explicitly.
package demo package demo
import java.util.LinkedList import java.util.ArrayList
class Test { class Test {
fun main() { fun main() {
val common = LinkedList<String>() val common = ArrayList<String>()
val raw = LinkedList<String>() val raw = ArrayList<String>()
val superRaw = LinkedList() val superRaw = ArrayList()
} }
} }
@@ -2,7 +2,7 @@
package a.b; package a.b;
class Base { class Base {
void foo(); void foo(){}
} }
class A extends Base { class A extends Base {
@@ -1,7 +1,9 @@
// ERROR: This type is final, so it cannot be inherited from
package a.b package a.b
class Base { class Base {
fun foo() fun foo() {
}
} }
class A : Base() { class A : Base() {
@@ -1,3 +1,4 @@
// ERROR: This type is final, so it cannot be inherited from
package a.b package a.b
class Base { class Base {
@@ -1,3 +1,5 @@
// ERROR: Null can not be a value of a non-null type kotlin.Iterator<kotlin.String>
// ERROR: Null can not be a value of a non-null type kotlin.Iterator<kotlin.String>
package demo package demo
class Test : Iterable<String> { class Test : Iterable<String> {
@@ -1,3 +1,5 @@
// ERROR: Null can not be a value of a non-null type kotlin.Iterator<kotlin.String>
// ERROR: Null can not be a value of a non-null type kotlin.Iterator<kotlin.String>
package demo package demo
import java.util.* import java.util.*
@@ -1,3 +1,4 @@
// ERROR: Null can not be a value of a non-null type kotlin.Iterator<kotlin.String>
package demo package demo
class Test : Iterable<String> { class Test : Iterable<String> {
@@ -1,3 +1,4 @@
// ERROR: Unresolved reference: bar
import java.io.IOException import java.io.IOException
class A { class A {

Some files were not shown because too many files have changed in this diff Show More