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 org.jetbrains.jet.j2k.IdeaReferenceSearcher
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() {
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 actual = reformat(rawConverted, project, reformatInFun)
var actual = reformat(rawConverted, project, reformatInFun)
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)
JetTestUtils.assertEqualsToFile(expectedFile, actual)
}
@@ -146,4 +160,8 @@ public abstract class AbstractJavaToKotlinConverterSingleFileTest() : AbstractJa
private fun createJavaFile(text: String): 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) { }
}
class T {
public class T {
public Set<String> set;
}
@@ -1,3 +1,4 @@
// ERROR: Body is not allowed for annotation class
annotation class Anon(public val value: String) {
public enum class E {
@@ -1,5 +1,5 @@
class Test {
String str;
static String str;
static {
str = "Ola";
}
@@ -1,7 +1,6 @@
class Test {
var str: String
class object {
var str: String
{
str = "Ola"
}
@@ -1,10 +1,10 @@
// !forceNotNullTypes: false
// !specifyLocalVariableTypeByDefault: true
import java.util.BitSet;
import java.util.HashSet;
class Foo {
void foo(BitSet o) {
BitSet o2 = o;
void foo(HashSet o) {
HashSet o2 = o;
int foo = 0;
foo = o2.size();
}
@@ -1,10 +1,10 @@
// !forceNotNullTypes: false
// !specifyLocalVariableTypeByDefault: true
import java.util.BitSet
import java.util.HashSet
class Foo {
fun foo(o: BitSet?) {
val o2: BitSet? = o
fun foo(o: HashSet<Any?>?) {
val o2: HashSet<Any?>? = o
var foo: Int = 0
foo = o2!!.size()
}
@@ -1,8 +1,8 @@
import java.util.BitSet;
import java.util.HashSet;
class Foo {
void foo(BitSet o) {
BitSet o2 = o;
void foo(HashSet o) {
HashSet o2 = o;
int foo = 0;
foo = o2.size();
}
@@ -1,7 +1,7 @@
import java.util.BitSet
import java.util.HashSet
class Foo {
fun foo(o: BitSet) {
fun foo(o: HashSet<Any>) {
val o2 = o
var foo = 0
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
class Test {
@@ -4,6 +4,6 @@ class Library {
class User {
void main() {
Library.ourOut.print();
Library.ourOut.print(1);
}
}
@@ -1,3 +1,4 @@
// ERROR: Property must be initialized or be abstract
class Library {
class object {
val ourOut: java.io.PrintStream
@@ -6,6 +7,6 @@ class Library {
class User {
fun main() {
Library.ourOut.print()
Library.ourOut.print(1)
}
}
@@ -4,6 +4,6 @@ class Library {
class User {
void main() {
Library.myString.isEmpty();
new Library().myString.isEmpty();
}
}
@@ -1,9 +1,10 @@
// ERROR: Property must be initialized or be abstract
class Library {
public val myString: String
}
class User {
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
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
// we use package 'foo'
@@ -11,9 +11,9 @@ class A {
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;
}
@@ -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
class A {
@@ -13,10 +15,10 @@ class A {
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 {
@@ -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 {
val __ = Test(null)
__.b = true
@@ -1,3 +1,4 @@
// ERROR: Property must be initialized or be abstract
class C(x: Any, b: Boolean) {
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 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> {
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 {
return Identifier(name, false)
}
@@ -5,6 +5,7 @@ class C {
int foo(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) {
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 {
val __ = C(arg1, arg2, 0)
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
}
private fun staticFoo(p: Int): Int {
return p
class object {
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
class A(nested: Nested = Nested(Nested.FIELD)) {
@@ -1,3 +1,4 @@
// ERROR: Property must be initialized or be abstract
package pack
import pack.A.Nested
@@ -1,3 +1,4 @@
// ERROR: Property must be initialized or be abstract
package pack
import pack.A.*
@@ -1,3 +1,4 @@
// ERROR: This type is final, so it cannot be inherited from
class Base(nested: Base.Nested) {
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 {
var arg2 = arg2
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 {
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 {
val __ = C(arg1, arg2, 0)
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 {
val __ = C()
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 {
return Test(null)
}
@@ -1,3 +1,4 @@
// ERROR: This type is final, so it cannot be inherited from
public class Base(x: Int) {
public var x: Int = 42
protected set
@@ -1,3 +1,4 @@
// ERROR: This type is final, so it cannot be inherited from
public class AAA {
public var x: Int = 42
protected set
@@ -1,3 +1,4 @@
// ERROR: Type mismatch: inferred type is kotlin.String? but kotlin.Any was expected
class A {
private val s: String? = null
@@ -1,3 +1,4 @@
// ERROR: This type is final, so it cannot be inherited from
class Base {
private val myFirst: String? = null
}
@@ -1,3 +1,5 @@
// ERROR: Unresolved reference: Foo
// ERROR: Property must be initialized or be abstract
class C {
var f: Foo
}
@@ -1,3 +1,4 @@
// ERROR: Unresolved reference: Foo
class C {
private val f: Foo? = null
}
@@ -1,3 +1,5 @@
// ERROR: Unresolved reference: Foo
// ERROR: Property must be initialized or be abstract
class C {
protected var f: Foo
}
@@ -1,3 +1,5 @@
// ERROR: Unresolved reference: Foo
// ERROR: Property must be initialized or be abstract
class C {
public var f: Foo
}
@@ -1,3 +1,4 @@
// ERROR: Unresolved reference: Foo
class C {
val f = Foo(1, 2)
}
@@ -1,3 +1,4 @@
// ERROR: Unresolved reference: Foo
class C {
var f = Foo(1, 2)
}
@@ -1,3 +1,5 @@
// ERROR: Unresolved reference: Foo
// ERROR: Property must be initialized or be abstract
class C {
var f: Foo
}
@@ -1,3 +1,4 @@
// ERROR: An integer literal does not conform to the expected type kotlin.Double
class A {
deprecated("")
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
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 {
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 {
fun foo() {
}
@@ -1,3 +1,4 @@
// ERROR: Unresolved reference: clone
class X {
override fun hashCode(): Int {
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 X : Base() {
@@ -1,3 +1,4 @@
// ERROR: This type is final, so it cannot be inherited from
class Base {
override fun equals(o: Any?): Boolean {
return super.equals(o)
@@ -1,3 +1,4 @@
// ERROR: This type is final, so it cannot be inherited from
class `$$$$$`
class `$`
@@ -1,3 +1,4 @@
// ERROR: Unresolved reference: `as`
package test
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.concurrent.ArrayBlockingQueue
@@ -1,3 +1,4 @@
// ERROR: This type is final, so it cannot be inherited from
class Base<T>(name: T)
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 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 One : Base()
@@ -1,3 +1,4 @@
// ERROR: This type is final, so it cannot be inherited from
class Base(name: String)
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
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 {
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> {
return Identifier(name, false)
}
@@ -1,3 +1,4 @@
// ERROR: This type is final, so it cannot be inherited from
package test
class Base {
@@ -3,7 +3,7 @@ import java.io.*;
class FileRead {
public static void main(String args[]) {
try {
FileInputStream fstream = new FileInputStream("textfile.txt");
FileInputStream fstream = new FileInputStream();
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
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.*
class FileRead {
class object {
public fun main(args: Array<String>) {
try {
val fstream = FileInputStream("textfile.txt")
val fstream = FileInputStream()
val `in` = DataInputStream(fstream)
val br = BufferedReader(InputStreamReader(`in`))
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
import java.io.Serializable
@@ -1,3 +1,4 @@
// ERROR: Variable cannot be initialized before declaration
package demo
class C(a: Int) {
@@ -1,3 +1,4 @@
// ERROR: No value passed for parameter field
import kotlinApi.*
class C : KotlinClass() {
@@ -1,3 +1,4 @@
// ERROR: Unresolved reference: LinkedList
import java.util.*
public class ForEach {
@@ -1,3 +1,4 @@
// ERROR: Unresolved reference: LinkedList
import java.util.*
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.*
class A {
@@ -1,3 +1,5 @@
// ERROR: Unresolved reference: ast2
// ERROR: Unresolved reference: ast
package test
import ast
@@ -1,3 +1,5 @@
// ERROR: Unresolved reference: ast2
// ERROR: Unresolved reference: ast
package test
import ast
@@ -1,3 +1,5 @@
// ERROR: Unresolved reference: ast2
// ERROR: Unresolved reference: ast
package test
import ast
@@ -1,3 +1,4 @@
// ERROR: Type mismatch: inferred type is T? but T was expected
import java.util.*
import kotlin.Collection
@@ -5,6 +5,6 @@ import java.util.List;
class User {
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
class User {
fun main() {
val list = java.util.LinkedList()
val list = java.util.ArrayList()
}
}
@@ -3,6 +3,6 @@ package test;
class User {
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
class User {
fun main() {
val list = java.util.LinkedList()
val list = java.util.ArrayList()
}
}
@@ -1,9 +1,9 @@
//file
import java.util.List;
import java.util.LinkedList;
import java.util.ArrayList;
class User {
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 {
fun main() {
val list = LinkedList<String>()
val list = ArrayList<String>()
}
}
@@ -2,13 +2,13 @@
package org.test;
import java.util.List;
import java.util.LinkedList;
import java.util.ArrayList;
class Member {}
class User {
void main() {
List<Member> members = new LinkedList<Member>();
List<Member> members = new ArrayList<Member>();
members.add(new Member());
}
}
@@ -1,12 +1,12 @@
package org.test
import java.util.LinkedList
import java.util.ArrayList
class Member
class User {
fun main() {
val members = LinkedList<Member>()
val members = ArrayList<Member>()
members.add(Member())
}
}
@@ -1,3 +1,4 @@
// ERROR: Unresolved reference: x
class C {
private val s = x()
@@ -1,3 +1,4 @@
// ERROR: Unresolved reference: x
class C {
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 {
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() {
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 {
public fun foo(s: String?): String? {
return ""
@@ -1,18 +1,26 @@
//file
package demo;
class WindowAdapter {
interface WindowListener {
void windowClosing ();
}
class WindowAdapter implements WindowListener {
public void windowClosing () {
}
}
class Frame {
public void addWindowListener(WindowListener listener){}
}
public final class Client extends Frame {
Client() {
WindowAdapter a = new WindowAdapter() {
@Override
public void windowClosing () {
}
}
};
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
class WindowAdapter {
public fun windowClosing() {
trait WindowListener {
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
import java.util.HashMap
@@ -2,12 +2,12 @@
package demo;
import java.util.List;
import java.util.LinkedList;
import java.util.ArrayList;
class Test {
void main() {
List<String> common = new LinkedList<String>();
List raw = new LinkedList<String>();
List superRaw = new LinkedList();
List<String> common = new ArrayList<String>();
List raw = new ArrayList<String>();
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
import java.util.LinkedList
import java.util.ArrayList
class Test {
fun main() {
val common = LinkedList<String>()
val raw = LinkedList<String>()
val superRaw = LinkedList()
val common = ArrayList<String>()
val raw = ArrayList<String>()
val superRaw = ArrayList()
}
}
@@ -2,7 +2,7 @@
package a.b;
class Base {
void foo();
void foo(){}
}
class A extends Base {
@@ -1,7 +1,9 @@
// ERROR: This type is final, so it cannot be inherited from
package a.b
class Base {
fun foo()
fun foo() {
}
}
class A : Base() {
@@ -1,3 +1,4 @@
// ERROR: This type is final, so it cannot be inherited from
package a.b
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
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
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
class Test : Iterable<String> {
@@ -1,3 +1,4 @@
// ERROR: Unresolved reference: bar
import java.io.IOException
class A {

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