New J2K: fix existing test data
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
//file
|
||||
package test;
|
||||
|
||||
class Test extends Base {
|
||||
@Override
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
// ERROR: Unresolved reference: clone
|
||||
// ERROR: Unresolved reference: finalize
|
||||
package test
|
||||
|
||||
internal class Test : Base() {
|
||||
internal class Test : Base(), Cloneable {
|
||||
override fun hashCode(): Int {
|
||||
return super.hashCode()
|
||||
}
|
||||
@@ -26,7 +24,7 @@ internal class Test : Base() {
|
||||
}
|
||||
}
|
||||
|
||||
internal open class Base {
|
||||
internal open class Base : Cloneable {
|
||||
override fun hashCode(): Int {
|
||||
return super.hashCode()
|
||||
}
|
||||
@@ -36,7 +34,7 @@ internal open class Base {
|
||||
}
|
||||
|
||||
@Throws(CloneNotSupportedException::class)
|
||||
protected open fun clone(): Any {
|
||||
override fun clone(): Any {
|
||||
return super.clone()
|
||||
}
|
||||
|
||||
|
||||
+11
-32
@@ -1,18 +1,8 @@
|
||||
// ERROR: 'return' is not allowed here
|
||||
// ERROR: Type mismatch: inferred type is String but Unit was expected
|
||||
// ERROR: 'return' is not allowed here
|
||||
// ERROR: Type mismatch: inferred type is String but Unit was expected
|
||||
// ERROR: 'return' is not allowed here
|
||||
// ERROR: Type mismatch: inferred type is String but Unit was expected
|
||||
class Java8Class {
|
||||
fun foo0(r: Function0<String>) {}
|
||||
|
||||
fun foo1(r: Function1<Int, String?>) {}
|
||||
|
||||
fun foo2(r: Function2<Int, Int, String>) {}
|
||||
|
||||
fun helper() {}
|
||||
|
||||
fun foo() {
|
||||
foo0 { "42" }
|
||||
foo0 { "42" }
|
||||
@@ -20,62 +10,51 @@ class Java8Class {
|
||||
helper()
|
||||
"42"
|
||||
}
|
||||
|
||||
foo1 { i -> "42" }
|
||||
foo1 { i -> "42" }
|
||||
foo1 { i: Int -> "42" }
|
||||
foo1 { i: Int -> "42" }
|
||||
foo1 { i: Int ->
|
||||
helper()
|
||||
if (i > 1) {
|
||||
return@foo1 "42"
|
||||
return@foo1 null
|
||||
}
|
||||
|
||||
"43"
|
||||
}
|
||||
|
||||
foo2 { i, j -> "42" }
|
||||
foo2 { i: Int, j: Int -> "42" }
|
||||
foo2 { i: Int, j: Int ->
|
||||
helper()
|
||||
"42"
|
||||
}
|
||||
|
||||
val f = { i: Int, k: Int ->
|
||||
val f = label@{ i: Int, k: Int ->
|
||||
helper()
|
||||
if (i > 1) {
|
||||
return "42"
|
||||
return@label "42"
|
||||
}
|
||||
|
||||
"43"
|
||||
}
|
||||
|
||||
val f1 = { i1: Int, k1: Int ->
|
||||
val f2 = { i2: Int, k2: Int ->
|
||||
val f1 = label@{ i1: Int, k1: Int ->
|
||||
val f2 = label@{ i2: Int, k2: Int ->
|
||||
helper()
|
||||
if (i2 > 1) {
|
||||
return "42"
|
||||
return@label "42"
|
||||
}
|
||||
|
||||
"43"
|
||||
}
|
||||
if (i1 > 1) {
|
||||
return f.invoke(i1, k1)
|
||||
return@label f.invoke(i1, k1)
|
||||
}
|
||||
f.invoke(i1, k1)
|
||||
}
|
||||
|
||||
val runnable = { }
|
||||
|
||||
val runnable = Runnable {}
|
||||
foo1 { i: Int ->
|
||||
if (i > 1) {
|
||||
return@foo1 "42"
|
||||
}
|
||||
|
||||
foo0 {
|
||||
if (true) {
|
||||
return@foo0 "42"
|
||||
}
|
||||
"43"
|
||||
}
|
||||
|
||||
"43"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,12 +79,13 @@ class Java8Class {
|
||||
constructorWithoutParams.invoke();
|
||||
|
||||
Function1<Integer, String> constructorWithParam = Test::testOverloads;
|
||||
constructorWithParam.invoke(2);
|
||||
constructorWithParam.invoke(2) + 42;
|
||||
}
|
||||
|
||||
public void testGenericFunctions() {
|
||||
Function0<List<String>> emptyList = Collections::emptyList;
|
||||
emptyList.invoke();
|
||||
List<String> list = emptyList.invoke();
|
||||
list.get(0);
|
||||
}
|
||||
|
||||
public static int staticFun() { return 1; }
|
||||
|
||||
+15
-22
@@ -1,8 +1,5 @@
|
||||
// ERROR: Type inference failed: Not enough information to infer parameter T in fun <T> emptyList(): List<T> Please specify it explicitly.
|
||||
package test
|
||||
|
||||
import java.util.Collections
|
||||
|
||||
internal class Test {
|
||||
fun memberFun(): Int {
|
||||
return 1
|
||||
@@ -28,10 +25,9 @@ internal class Java8Class {
|
||||
private val field = Java8Class()
|
||||
|
||||
fun testStaticFunction() {
|
||||
val staticFunFromSameClass = { staticFun() }
|
||||
val staticFunFromSameClass: Function0<*> = { staticFun() }
|
||||
staticFunFromSameClass.invoke()
|
||||
|
||||
val staticFunFromAnotherClass = { Test.staticFun() }
|
||||
val staticFunFromAnotherClass: Function0<*> = { Test.staticFun() }
|
||||
staticFunFromAnotherClass.invoke()
|
||||
}
|
||||
|
||||
@@ -42,32 +38,28 @@ internal class Java8Class {
|
||||
|
||||
fun testMemberFunctionThroughObject() {
|
||||
val obj = Java8Class()
|
||||
val memberFunFromSameClass = { obj.memberFun() }
|
||||
val memberFunFromSameClass: Function0<*> = { obj.memberFun() }
|
||||
memberFunFromSameClass.invoke()
|
||||
|
||||
val anotherObj = Test()
|
||||
val memFunFromAnotherClass = { anotherObj.memberFun() }
|
||||
val memFunFromAnotherClass: Function0<*> = { anotherObj.memberFun() }
|
||||
memFunFromAnotherClass.invoke()
|
||||
|
||||
val memberFunThroughObj1 = { field.memberFun() }
|
||||
val memberFunThroughObj1: Function0<*> = { field.memberFun() }
|
||||
memberFunThroughObj1.invoke()
|
||||
val memberFunThroughObj2 = { Test.field.memberFun() }
|
||||
val memberFunThroughObj2: Function0<*> = { Test.field.memberFun() }
|
||||
memberFunThroughObj2.invoke()
|
||||
val memberFunThroughObj3 = { Test.staticFun().memberFun() }
|
||||
val memberFunThroughObj3: Function0<*> = { Test.staticFun().memberFun() }
|
||||
memberFunThroughObj3.invoke()
|
||||
}
|
||||
|
||||
fun testConstructor() {
|
||||
val constructorSameClass = { Java8Class() }
|
||||
val constructorSameClass: Function0<*> = { Java8Class() }
|
||||
constructorSameClass.invoke()
|
||||
|
||||
val qualifiedConstructorSameClass = { test.Java8Class() }
|
||||
val qualifiedConstructorSameClass: Function0<*> = { Java8Class() }
|
||||
qualifiedConstructorSameClass.invoke()
|
||||
|
||||
val constructorAnotherClass = { Test() }
|
||||
val constructorAnotherClass: Function0<*> = { Test() }
|
||||
constructorAnotherClass.invoke()
|
||||
|
||||
val qualifiedConstructorAnotherClass = { test.Test() }
|
||||
val qualifiedConstructorAnotherClass: Function0<*> = { Test() }
|
||||
qualifiedConstructorAnotherClass.invoke()
|
||||
}
|
||||
|
||||
@@ -81,12 +73,13 @@ internal class Java8Class {
|
||||
constructorWithoutParams.invoke()
|
||||
|
||||
val constructorWithParam = { i: Int -> Test.testOverloads(i) }
|
||||
constructorWithParam.invoke(2)
|
||||
constructorWithParam.invoke(2) + 42
|
||||
}
|
||||
|
||||
fun testGenericFunctions() {
|
||||
val emptyList = { emptyList() }
|
||||
emptyList.invoke()
|
||||
val emptyList: Function0<kotlin.collections.List<String>> = { emptyList() }
|
||||
val list = emptyList.invoke()
|
||||
list[0]
|
||||
}
|
||||
|
||||
fun memberFun(): Int {
|
||||
|
||||
+20
-32
@@ -1,7 +1,6 @@
|
||||
package test
|
||||
|
||||
import javaApi.*
|
||||
import java.util.Collections
|
||||
|
||||
internal class Test {
|
||||
fun memberFun(): Int {
|
||||
@@ -9,7 +8,6 @@ internal class Test {
|
||||
}
|
||||
|
||||
constructor(i: Int) : super() {}
|
||||
|
||||
constructor() {}
|
||||
|
||||
companion object {
|
||||
@@ -29,17 +27,14 @@ internal class Test {
|
||||
}
|
||||
|
||||
internal class Test2
|
||||
|
||||
internal class Java8Class {
|
||||
private val field = Java8Class()
|
||||
private val h = MethodReferenceHelperClass()
|
||||
|
||||
fun testStaticFunction() {
|
||||
val staticFunFromSameClass = JFunction0 { staticFun() }
|
||||
staticFunFromSameClass.foo()
|
||||
MethodReferenceHelperClass.staticFun0 { staticFun() }
|
||||
h.memberFun0 { staticFun() }
|
||||
|
||||
val staticFunFromAnotherClass = JFunction0 { Test.staticFun() }
|
||||
staticFunFromAnotherClass.foo()
|
||||
MethodReferenceHelperClass.staticFun0 { Test.staticFun() }
|
||||
@@ -47,10 +42,10 @@ internal class Java8Class {
|
||||
}
|
||||
|
||||
fun testMemberFunctionThroughClass() {
|
||||
val memberFunFromClass = JFunction2<Java8Class, Int> { it.memberFun() }
|
||||
val memberFunFromClass: JFunction2<Java8Class, Int> = JFunction2 { obj: Java8Class -> obj.memberFun() }
|
||||
memberFunFromClass.foo(Java8Class())
|
||||
MethodReferenceHelperClass.staticFun2(JFunction2<Java8Class, Int> { it.memberFun() })
|
||||
h.memberFun2(JFunction2<Java8Class, Int> { it.memberFun() })
|
||||
MethodReferenceHelperClass.staticFun2 { obj: Java8Class -> obj.memberFun() }
|
||||
h.memberFun2 { obj: Java8Class -> obj.memberFun() }
|
||||
}
|
||||
|
||||
fun testMemberFunctionThroughObject() {
|
||||
@@ -87,27 +82,22 @@ internal class Java8Class {
|
||||
constructorSameClass.foo()
|
||||
MethodReferenceHelperClass.staticFun0 { Java8Class() }
|
||||
h.memberFun0 { Java8Class() }
|
||||
|
||||
val qualifiedConstructorSameClass = JFunction0 { test.Java8Class() }
|
||||
val qualifiedConstructorSameClass = JFunction0 { Java8Class() }
|
||||
qualifiedConstructorSameClass.foo()
|
||||
MethodReferenceHelperClass.staticFun0 { test.Java8Class() }
|
||||
h.memberFun0 { test.Java8Class() }
|
||||
|
||||
MethodReferenceHelperClass.staticFun0 { Java8Class() }
|
||||
h.memberFun0 { Java8Class() }
|
||||
val constructorAnotherClass = JFunction0 { Test() }
|
||||
constructorAnotherClass.foo()
|
||||
MethodReferenceHelperClass.staticFun0 { Test() }
|
||||
h.memberFun0 { Test() }
|
||||
|
||||
val constructorAnotherClassWithParam = JFunction2<Int, Test> { Test(it) }
|
||||
val constructorAnotherClassWithParam: JFunction2<Int, Test> = JFunction2 { i: Int -> Test(i) }
|
||||
constructorAnotherClassWithParam.foo(1)
|
||||
MethodReferenceHelperClass.staticFun2(JFunction2<Int, Test> { Test(it) })
|
||||
h.memberFun2(JFunction2<Int, Test> { Test(it) })
|
||||
|
||||
val qualifiedConstructorAnotherClass = JFunction0 { test.Test() }
|
||||
MethodReferenceHelperClass.staticFun2 { i: Int -> Test(i) }
|
||||
h.memberFun2 { i: Int -> Test(i) }
|
||||
val qualifiedConstructorAnotherClass = JFunction0 { Test() }
|
||||
qualifiedConstructorAnotherClass.foo()
|
||||
MethodReferenceHelperClass.staticFun0 { test.Test() }
|
||||
h.memberFun0 { test.Test() }
|
||||
|
||||
MethodReferenceHelperClass.staticFun0 { Test() }
|
||||
h.memberFun0 { Test() }
|
||||
val constructorAnotherClassWithoutConstructor = JFunction0 { Test2() }
|
||||
constructorAnotherClassWithoutConstructor.foo()
|
||||
MethodReferenceHelperClass.staticFun0 { Test2() }
|
||||
@@ -115,30 +105,28 @@ internal class Java8Class {
|
||||
}
|
||||
|
||||
fun testLibraryFunctions() {
|
||||
val memberFunFromClass = JFunction2<String, Int> { it.length }
|
||||
val memberFunFromClass: JFunction2<String, Int> = JFunction2 { obj: String -> obj.length }
|
||||
memberFunFromClass.foo("str")
|
||||
|
||||
Thread(Runnable { println() }).start()
|
||||
Runnable { println() }.run()
|
||||
}
|
||||
|
||||
fun testOverloads() {
|
||||
val constructorWithoutParams = JFunction1 { Test.testOverloads() }
|
||||
val constructorWithoutParams: JFunction1<String> = JFunction1 { Test.testOverloads() }
|
||||
constructorWithoutParams.foo()
|
||||
MethodReferenceHelperClass.staticFun1 { Test.testOverloads() }
|
||||
h.memberFun1 { Test.testOverloads() }
|
||||
|
||||
val constructorWithParam = JFunction2<Int, String> { Test.testOverloads(it) }
|
||||
val constructorWithParam: JFunction2<Int, String> = JFunction2 { i: Int -> Test.testOverloads(i) }
|
||||
constructorWithParam.foo(2)
|
||||
MethodReferenceHelperClass.staticFun2(JFunction2<Int, String> { Test.testOverloads(it) })
|
||||
h.memberFun2(JFunction2<Int, String> { Test.testOverloads(it) })
|
||||
MethodReferenceHelperClass.staticFun2 { i: Int -> Test.testOverloads(i) }
|
||||
h.memberFun2 { i: Int -> Test.testOverloads(i) }
|
||||
}
|
||||
|
||||
fun testGenericFunctions() {
|
||||
val emptyList = JFunction1<List<String>> { emptyList() }
|
||||
val emptyList: JFunction1<kotlin.collections.List<String>> = JFunction1 { emptyList() }
|
||||
emptyList.foo()
|
||||
MethodReferenceHelperClass.staticFun1(JFunction1<List<String>> { emptyList() })
|
||||
h.memberFun1(JFunction1<List<String>> { emptyList() })
|
||||
MethodReferenceHelperClass.staticFun1(JFunction1<kotlin.collections.List<String>> { emptyList() })
|
||||
h.memberFun1(JFunction1<kotlin.collections.List<String>> { emptyList() })
|
||||
}
|
||||
|
||||
fun memberFun(): Int {
|
||||
|
||||
Reference in New Issue
Block a user