New J2K: Split old j2k and new j2k tests
This commit is contained in:
committed by
Ilya Kirillov
parent
02a206bf7c
commit
b411e8e18e
@@ -0,0 +1,2 @@
|
||||
//method
|
||||
abstract int getNoofGears();
|
||||
@@ -0,0 +1 @@
|
||||
internal abstract val noofGears: Int
|
||||
@@ -0,0 +1,2 @@
|
||||
//method
|
||||
T getT() {}
|
||||
@@ -0,0 +1,2 @@
|
||||
val t: T?
|
||||
get() {}
|
||||
@@ -0,0 +1,2 @@
|
||||
//method
|
||||
void main() {}
|
||||
@@ -0,0 +1 @@
|
||||
fun main() {}
|
||||
@@ -0,0 +1,56 @@
|
||||
//file
|
||||
package test;
|
||||
|
||||
class Test extends Base {
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return super.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return super.equals(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object clone() throws CloneNotSupportedException {
|
||||
return super.clone();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return super.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void finalize() throws Throwable {
|
||||
super.finalize();
|
||||
}
|
||||
}
|
||||
|
||||
class Base {
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return super.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return super.equals(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object clone() throws CloneNotSupportedException {
|
||||
return super.clone();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return super.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void finalize() throws Throwable {
|
||||
super.finalize();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
// ERROR: Unresolved reference: clone
|
||||
// ERROR: Unresolved reference: finalize
|
||||
package test
|
||||
|
||||
internal class Test : Base() {
|
||||
override fun hashCode(): Int {
|
||||
return super.hashCode()
|
||||
}
|
||||
|
||||
override fun equals(o: Any?): Boolean {
|
||||
return super.equals(o)
|
||||
}
|
||||
|
||||
@Throws(CloneNotSupportedException::class)
|
||||
override fun clone(): Any {
|
||||
return super.clone()
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
return super.toString()
|
||||
}
|
||||
|
||||
@Throws(Throwable::class)
|
||||
override fun finalize() {
|
||||
super.finalize()
|
||||
}
|
||||
}
|
||||
|
||||
internal open class Base {
|
||||
override fun hashCode(): Int {
|
||||
return super.hashCode()
|
||||
}
|
||||
|
||||
override fun equals(o: Any?): Boolean {
|
||||
return super.equals(o)
|
||||
}
|
||||
|
||||
@Throws(CloneNotSupportedException::class)
|
||||
protected open fun clone(): Any {
|
||||
return super.clone()
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
return super.toString()
|
||||
}
|
||||
|
||||
@Throws(Throwable::class)
|
||||
protected open fun finalize() {
|
||||
super.finalize()
|
||||
}
|
||||
}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
//method
|
||||
final String getString() { return ""; }
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
val string: String
|
||||
get() = ""
|
||||
@@ -0,0 +1,6 @@
|
||||
//file
|
||||
package demo;
|
||||
|
||||
final class Final {
|
||||
void test() {}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package demo
|
||||
|
||||
internal class Final {
|
||||
fun test() {}
|
||||
}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
//method
|
||||
void test() {}
|
||||
+1
@@ -0,0 +1 @@
|
||||
fun test() {}
|
||||
+84
@@ -0,0 +1,84 @@
|
||||
import kotlin.jvm.functions.Function0;
|
||||
import kotlin.jvm.functions.Function1;
|
||||
import kotlin.jvm.functions.Function2;
|
||||
|
||||
public class Java8Class {
|
||||
public void foo0(Function0<String> r) {
|
||||
}
|
||||
|
||||
public void foo1(Function1<Integer, String> r) {
|
||||
}
|
||||
|
||||
public void foo2(Function2<Integer, Integer, String> r) {
|
||||
}
|
||||
|
||||
public void helper() {
|
||||
}
|
||||
|
||||
public void foo() {
|
||||
foo0(() -> "42");
|
||||
foo0(() -> { return "42"; });
|
||||
foo0(() -> {
|
||||
helper();
|
||||
return "42";
|
||||
});
|
||||
|
||||
foo1((i) -> "42");
|
||||
foo1(i -> { return "42"; });
|
||||
foo1((Integer i) -> {
|
||||
helper();
|
||||
if (i > 1) {
|
||||
return "42";
|
||||
}
|
||||
|
||||
return "43";
|
||||
});
|
||||
|
||||
foo2((i, j) -> "42");
|
||||
foo2((Integer i, Integer j) -> {
|
||||
helper();
|
||||
return "42";
|
||||
});
|
||||
|
||||
Function2<Integer, Integer, String> f = (Integer i, Integer k) -> {
|
||||
helper();
|
||||
if (i > 1) {
|
||||
return "42";
|
||||
}
|
||||
|
||||
return "43";
|
||||
};
|
||||
|
||||
Function2<Integer, Integer, String> f1 = (Integer i1, Integer k1) -> {
|
||||
Function2<Integer, Integer, String> f2 = (Integer i2, Integer k2) -> {
|
||||
helper();
|
||||
if (i2 > 1) {
|
||||
return "42";
|
||||
}
|
||||
|
||||
return "43";
|
||||
};
|
||||
if (i1 > 1) {
|
||||
return f.invoke(i1, k1);
|
||||
}
|
||||
return f.invoke(i1, k1);
|
||||
};
|
||||
|
||||
Runnable runnable = () -> { };
|
||||
|
||||
foo1((Integer i) -> {
|
||||
if (i > 1) {
|
||||
return "42";
|
||||
}
|
||||
|
||||
foo0(() -> {
|
||||
if (true) {
|
||||
return "42";
|
||||
}
|
||||
return "43";
|
||||
});
|
||||
|
||||
return "43";
|
||||
});
|
||||
}
|
||||
}
|
||||
+82
@@ -0,0 +1,82 @@
|
||||
// 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" }
|
||||
foo0 {
|
||||
helper()
|
||||
"42"
|
||||
}
|
||||
|
||||
foo1 { i -> "42" }
|
||||
foo1 { i -> "42" }
|
||||
foo1 { i: Int ->
|
||||
helper()
|
||||
if (i > 1) {
|
||||
return@foo1 "42"
|
||||
}
|
||||
|
||||
"43"
|
||||
}
|
||||
|
||||
foo2 { i, j -> "42" }
|
||||
foo2 { i: Int, j: Int ->
|
||||
helper()
|
||||
"42"
|
||||
}
|
||||
|
||||
val f = { i: Int, k: Int ->
|
||||
helper()
|
||||
if (i > 1) {
|
||||
return "42"
|
||||
}
|
||||
|
||||
"43"
|
||||
}
|
||||
|
||||
val f1 = { i1: Int, k1: Int ->
|
||||
val f2 = { i2: Int, k2: Int ->
|
||||
helper()
|
||||
if (i2 > 1) {
|
||||
return "42"
|
||||
}
|
||||
|
||||
"43"
|
||||
}
|
||||
if (i1 > 1) {
|
||||
return f.invoke(i1, k1)
|
||||
}
|
||||
f.invoke(i1, k1)
|
||||
}
|
||||
|
||||
val runnable = { }
|
||||
|
||||
foo1 { i: Int ->
|
||||
if (i > 1) {
|
||||
return@foo1 "42"
|
||||
}
|
||||
|
||||
foo0 {
|
||||
if (true) {
|
||||
return@foo0 "42"
|
||||
}
|
||||
"43"
|
||||
}
|
||||
|
||||
"43"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
package test;
|
||||
|
||||
import kotlin.jvm.functions.Function0;
|
||||
import kotlin.jvm.functions.Function1;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
class Test {
|
||||
public static Java8Class field = new Java8Class();
|
||||
public static Java8Class staticFun() {
|
||||
return new Java8Class();
|
||||
}
|
||||
public int memberFun() {return 1;}
|
||||
|
||||
public static String testOverloads() {
|
||||
return "1";
|
||||
}
|
||||
|
||||
public static String testOverloads(int i) {
|
||||
return "2";
|
||||
}
|
||||
}
|
||||
|
||||
class Java8Class {
|
||||
private Java8Class field = new Java8Class();
|
||||
|
||||
public void testStaticFunction() {
|
||||
Function0 staticFunFromSameClass = Java8Class::staticFun;
|
||||
staticFunFromSameClass.invoke();
|
||||
|
||||
Function0 staticFunFromAnotherClass = Test::staticFun;
|
||||
staticFunFromAnotherClass.invoke();
|
||||
}
|
||||
|
||||
public void testMemberFunctionThroughClass() {
|
||||
Function1<Java8Class, Integer> memberFunFromClass = Java8Class::memberFun;
|
||||
memberFunFromClass.invoke(new Java8Class());
|
||||
}
|
||||
|
||||
public void testMemberFunctionThroughObject() {
|
||||
Java8Class obj = new Java8Class();
|
||||
Function0 memberFunFromSameClass = obj::memberFun;
|
||||
memberFunFromSameClass.invoke();
|
||||
|
||||
Test anotherObj = new Test();
|
||||
Function0 memFunFromAnotherClass = anotherObj::memberFun;
|
||||
memFunFromAnotherClass.invoke();
|
||||
|
||||
Function0 memberFunThroughObj1 = field::memberFun;
|
||||
memberFunThroughObj1.invoke();
|
||||
Function0 memberFunThroughObj2 = Test.field::memberFun;
|
||||
memberFunThroughObj2.invoke();
|
||||
Function0 memberFunThroughObj3 = Test.staticFun()::memberFun;
|
||||
memberFunThroughObj3.invoke();
|
||||
}
|
||||
|
||||
public void testConstructor() {
|
||||
Function0 constructorSameClass = Java8Class::new;
|
||||
constructorSameClass.invoke();
|
||||
|
||||
Function0 qualifiedConstructorSameClass = test.Java8Class::new;
|
||||
qualifiedConstructorSameClass.invoke();
|
||||
|
||||
Function0 constructorAnotherClass = Test::new;
|
||||
constructorAnotherClass.invoke();
|
||||
|
||||
Function0 qualifiedConstructorAnotherClass = test.Test::new;
|
||||
qualifiedConstructorAnotherClass.invoke();
|
||||
}
|
||||
|
||||
public void testLibraryFunctions() {
|
||||
Function1<String, Integer> memberFunFromClass = String::length;
|
||||
memberFunFromClass.invoke("str");
|
||||
}
|
||||
|
||||
public void testOverloads() {
|
||||
Function0<String> constructorWithoutParams = Test::testOverloads;
|
||||
constructorWithoutParams.invoke();
|
||||
|
||||
Function1<Integer, String> constructorWithParam = Test::testOverloads;
|
||||
constructorWithParam.invoke(2);
|
||||
}
|
||||
|
||||
public void testGenericFunctions() {
|
||||
Function0<List<String>> emptyList = Collections::emptyList;
|
||||
emptyList.invoke();
|
||||
}
|
||||
|
||||
public static int staticFun() { return 1; }
|
||||
|
||||
public int memberFun() { return 1; }
|
||||
|
||||
public Java8Class() {}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
// 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
|
||||
}
|
||||
|
||||
companion object {
|
||||
var field = Java8Class()
|
||||
fun staticFun(): Java8Class {
|
||||
return Java8Class()
|
||||
}
|
||||
|
||||
fun testOverloads(): String {
|
||||
return "1"
|
||||
}
|
||||
|
||||
fun testOverloads(i: Int): String {
|
||||
return "2"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal class Java8Class {
|
||||
private val field = Java8Class()
|
||||
|
||||
fun testStaticFunction() {
|
||||
val staticFunFromSameClass = { staticFun() }
|
||||
staticFunFromSameClass.invoke()
|
||||
|
||||
val staticFunFromAnotherClass = { Test.staticFun() }
|
||||
staticFunFromAnotherClass.invoke()
|
||||
}
|
||||
|
||||
fun testMemberFunctionThroughClass() {
|
||||
val memberFunFromClass = { obj: Java8Class -> obj.memberFun() }
|
||||
memberFunFromClass.invoke(Java8Class())
|
||||
}
|
||||
|
||||
fun testMemberFunctionThroughObject() {
|
||||
val obj = Java8Class()
|
||||
val memberFunFromSameClass = { obj.memberFun() }
|
||||
memberFunFromSameClass.invoke()
|
||||
|
||||
val anotherObj = Test()
|
||||
val memFunFromAnotherClass = { anotherObj.memberFun() }
|
||||
memFunFromAnotherClass.invoke()
|
||||
|
||||
val memberFunThroughObj1 = { field.memberFun() }
|
||||
memberFunThroughObj1.invoke()
|
||||
val memberFunThroughObj2 = { Test.field.memberFun() }
|
||||
memberFunThroughObj2.invoke()
|
||||
val memberFunThroughObj3 = { Test.staticFun().memberFun() }
|
||||
memberFunThroughObj3.invoke()
|
||||
}
|
||||
|
||||
fun testConstructor() {
|
||||
val constructorSameClass = { Java8Class() }
|
||||
constructorSameClass.invoke()
|
||||
|
||||
val qualifiedConstructorSameClass = { test.Java8Class() }
|
||||
qualifiedConstructorSameClass.invoke()
|
||||
|
||||
val constructorAnotherClass = { Test() }
|
||||
constructorAnotherClass.invoke()
|
||||
|
||||
val qualifiedConstructorAnotherClass = { test.Test() }
|
||||
qualifiedConstructorAnotherClass.invoke()
|
||||
}
|
||||
|
||||
fun testLibraryFunctions() {
|
||||
val memberFunFromClass = { obj: String -> obj.length }
|
||||
memberFunFromClass.invoke("str")
|
||||
}
|
||||
|
||||
fun testOverloads() {
|
||||
val constructorWithoutParams = { Test.testOverloads() }
|
||||
constructorWithoutParams.invoke()
|
||||
|
||||
val constructorWithParam = { i: Int -> Test.testOverloads(i) }
|
||||
constructorWithParam.invoke(2)
|
||||
}
|
||||
|
||||
fun testGenericFunctions() {
|
||||
val emptyList = { emptyList() }
|
||||
emptyList.invoke()
|
||||
}
|
||||
|
||||
fun memberFun(): Int {
|
||||
return 1
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
fun staticFun(): Int {
|
||||
return 1
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
package test;
|
||||
|
||||
import javaApi.*;
|
||||
|
||||
import java.lang.Integer;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
class Test {
|
||||
public static Java8Class field = new Java8Class();
|
||||
public static Java8Class staticFun() {
|
||||
return new Java8Class();
|
||||
}
|
||||
public int memberFun() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
public static String testOverloads() {
|
||||
return "1";
|
||||
}
|
||||
|
||||
public static String testOverloads(int i) {
|
||||
return "2";
|
||||
}
|
||||
|
||||
public Test(int i) {
|
||||
super();
|
||||
}
|
||||
|
||||
public Test() {
|
||||
}
|
||||
}
|
||||
|
||||
class Test2 {}
|
||||
|
||||
class Java8Class {
|
||||
private Java8Class field = new Java8Class();
|
||||
private MethodReferenceHelperClass h = new MethodReferenceHelperClass();
|
||||
|
||||
public void testStaticFunction() {
|
||||
JFunction0 staticFunFromSameClass = Java8Class::staticFun;
|
||||
staticFunFromSameClass.foo();
|
||||
MethodReferenceHelperClass.staticFun0(Java8Class::staticFun);
|
||||
h.memberFun0(Java8Class::staticFun);
|
||||
|
||||
JFunction0 staticFunFromAnotherClass = Test::staticFun;
|
||||
staticFunFromAnotherClass.foo();
|
||||
MethodReferenceHelperClass.staticFun0(Test::staticFun);
|
||||
h.memberFun0(Test::staticFun);
|
||||
}
|
||||
|
||||
public void testMemberFunctionThroughClass() {
|
||||
JFunction2<Java8Class, Integer> memberFunFromClass = Java8Class::memberFun;
|
||||
memberFunFromClass.foo(new Java8Class());
|
||||
MethodReferenceHelperClass.staticFun2(Java8Class::memberFun);
|
||||
h.memberFun2(Java8Class::memberFun);
|
||||
}
|
||||
|
||||
public void testMemberFunctionThroughObject() {
|
||||
Java8Class obj = new Java8Class();
|
||||
JFunction0 memberFunFromSameClass = obj::memberFun;
|
||||
memberFunFromSameClass.foo();
|
||||
MethodReferenceHelperClass.staticFun0(obj::memberFun);
|
||||
h.memberFun0(obj::memberFun);
|
||||
|
||||
Test anotherObj = new Test();
|
||||
JFunction0 memFunFromAnotherClass = anotherObj::memberFun;
|
||||
memFunFromAnotherClass.foo();
|
||||
MethodReferenceHelperClass.staticFun0(anotherObj::memberFun);
|
||||
h.memberFun0(anotherObj::memberFun);
|
||||
|
||||
JFunction0 memberFunThroughObj1 = field::memberFun;
|
||||
memberFunThroughObj1.foo();
|
||||
MethodReferenceHelperClass.staticFun0(field::memberFun);
|
||||
h.memberFun0(field::memberFun);
|
||||
|
||||
JFunction0 memberFunThroughObj2 = Test.field::memberFun;
|
||||
memberFunThroughObj2.foo();
|
||||
MethodReferenceHelperClass.staticFun0(Test.field::memberFun);
|
||||
h.memberFun0(Test.field::memberFun);
|
||||
|
||||
JFunction0 memberFunThroughObj3 = Test.staticFun()::memberFun;
|
||||
memberFunThroughObj3.foo();
|
||||
MethodReferenceHelperClass.staticFun0(Test.staticFun()::memberFun);
|
||||
h.memberFun0(Test.staticFun()::memberFun);
|
||||
}
|
||||
|
||||
public void testConstructor() {
|
||||
JFunction0 constructorSameClass = Java8Class::new;
|
||||
constructorSameClass.foo();
|
||||
MethodReferenceHelperClass.staticFun0(Java8Class::new);
|
||||
h.memberFun0(Java8Class::new);
|
||||
|
||||
JFunction0 qualifiedConstructorSameClass = test.Java8Class::new;
|
||||
qualifiedConstructorSameClass.foo();
|
||||
MethodReferenceHelperClass.staticFun0(test.Java8Class::new);
|
||||
h.memberFun0(test.Java8Class::new);
|
||||
|
||||
JFunction0 constructorAnotherClass = Test::new;
|
||||
constructorAnotherClass.foo();
|
||||
MethodReferenceHelperClass.staticFun0(Test::new);
|
||||
h.memberFun0(Test::new);
|
||||
|
||||
JFunction2<Integer, Test> constructorAnotherClassWithParam = Test::new;
|
||||
constructorAnotherClassWithParam.foo(1);
|
||||
MethodReferenceHelperClass.<Integer, Test>staticFun2(Test::new);
|
||||
h.<Integer, Test>memberFun2(Test::new);
|
||||
|
||||
JFunction0 qualifiedConstructorAnotherClass = test.Test::new;
|
||||
qualifiedConstructorAnotherClass.foo();
|
||||
MethodReferenceHelperClass.staticFun0(test.Test::new);
|
||||
h.memberFun0(test.Test::new);
|
||||
|
||||
JFunction0 constructorAnotherClassWithoutConstructor = Test2::new;
|
||||
constructorAnotherClassWithoutConstructor.foo();
|
||||
MethodReferenceHelperClass.staticFun0(Test2::new);
|
||||
h.memberFun0(Test2::new);
|
||||
}
|
||||
|
||||
public void testLibraryFunctions() {
|
||||
JFunction2<String, Integer> memberFunFromClass = String::length;
|
||||
memberFunFromClass.foo("str");
|
||||
|
||||
new Thread(System.out::println).start();
|
||||
((Runnable) System.out::println).run();
|
||||
}
|
||||
|
||||
public void testOverloads() {
|
||||
JFunction1<String> constructorWithoutParams = Test::testOverloads;
|
||||
constructorWithoutParams.foo();
|
||||
MethodReferenceHelperClass.<String>staticFun1(Test::testOverloads);
|
||||
h.<String>memberFun1(Test::testOverloads);
|
||||
|
||||
JFunction2<Integer, String> constructorWithParam = Test::testOverloads;
|
||||
constructorWithParam.foo(2);
|
||||
MethodReferenceHelperClass.<Integer, String>staticFun2(Test::testOverloads);
|
||||
h.<Integer, String>memberFun2(Test::testOverloads);
|
||||
}
|
||||
|
||||
public void testGenericFunctions() {
|
||||
JFunction1<List<String>> emptyList = Collections::emptyList;
|
||||
emptyList.foo();
|
||||
MethodReferenceHelperClass.<List<String>>staticFun1(Collections::emptyList);
|
||||
h.<List<String>>memberFun1(Collections::emptyList);
|
||||
}
|
||||
|
||||
public static int staticFun() { return 1; }
|
||||
|
||||
public int memberFun() { return 1; }
|
||||
|
||||
public Java8Class() {}
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
package test
|
||||
|
||||
import javaApi.*
|
||||
import java.util.Collections
|
||||
|
||||
internal class Test {
|
||||
fun memberFun(): Int {
|
||||
return 1
|
||||
}
|
||||
|
||||
constructor(i: Int) : super() {}
|
||||
|
||||
constructor() {}
|
||||
|
||||
companion object {
|
||||
var field = Java8Class()
|
||||
fun staticFun(): Java8Class {
|
||||
return Java8Class()
|
||||
}
|
||||
|
||||
fun testOverloads(): String {
|
||||
return "1"
|
||||
}
|
||||
|
||||
fun testOverloads(i: Int): String {
|
||||
return "2"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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() }
|
||||
h.memberFun0 { Test.staticFun() }
|
||||
}
|
||||
|
||||
fun testMemberFunctionThroughClass() {
|
||||
val memberFunFromClass = JFunction2<Java8Class, Int> { it.memberFun() }
|
||||
memberFunFromClass.foo(Java8Class())
|
||||
MethodReferenceHelperClass.staticFun2(JFunction2<Java8Class, Int> { it.memberFun() })
|
||||
h.memberFun2(JFunction2<Java8Class, Int> { it.memberFun() })
|
||||
}
|
||||
|
||||
fun testMemberFunctionThroughObject() {
|
||||
val obj = Java8Class()
|
||||
val memberFunFromSameClass = JFunction0 { obj.memberFun() }
|
||||
memberFunFromSameClass.foo()
|
||||
MethodReferenceHelperClass.staticFun0 { obj.memberFun() }
|
||||
h.memberFun0 { obj.memberFun() }
|
||||
|
||||
val anotherObj = Test()
|
||||
val memFunFromAnotherClass = JFunction0 { anotherObj.memberFun() }
|
||||
memFunFromAnotherClass.foo()
|
||||
MethodReferenceHelperClass.staticFun0 { anotherObj.memberFun() }
|
||||
h.memberFun0 { anotherObj.memberFun() }
|
||||
|
||||
val memberFunThroughObj1 = JFunction0 { field.memberFun() }
|
||||
memberFunThroughObj1.foo()
|
||||
MethodReferenceHelperClass.staticFun0 { field.memberFun() }
|
||||
h.memberFun0 { field.memberFun() }
|
||||
|
||||
val memberFunThroughObj2 = JFunction0 { Test.field.memberFun() }
|
||||
memberFunThroughObj2.foo()
|
||||
MethodReferenceHelperClass.staticFun0 { Test.field.memberFun() }
|
||||
h.memberFun0 { Test.field.memberFun() }
|
||||
|
||||
val memberFunThroughObj3 = JFunction0 { Test.staticFun().memberFun() }
|
||||
memberFunThroughObj3.foo()
|
||||
MethodReferenceHelperClass.staticFun0 { Test.staticFun().memberFun() }
|
||||
h.memberFun0 { Test.staticFun().memberFun() }
|
||||
}
|
||||
|
||||
fun testConstructor() {
|
||||
val constructorSameClass = JFunction0 { Java8Class() }
|
||||
constructorSameClass.foo()
|
||||
MethodReferenceHelperClass.staticFun0 { Java8Class() }
|
||||
h.memberFun0 { Java8Class() }
|
||||
|
||||
val qualifiedConstructorSameClass = JFunction0 { test.Java8Class() }
|
||||
qualifiedConstructorSameClass.foo()
|
||||
MethodReferenceHelperClass.staticFun0 { test.Java8Class() }
|
||||
h.memberFun0 { test.Java8Class() }
|
||||
|
||||
val constructorAnotherClass = JFunction0 { Test() }
|
||||
constructorAnotherClass.foo()
|
||||
MethodReferenceHelperClass.staticFun0 { Test() }
|
||||
h.memberFun0 { Test() }
|
||||
|
||||
val constructorAnotherClassWithParam = JFunction2<Int, Test> { Test(it) }
|
||||
constructorAnotherClassWithParam.foo(1)
|
||||
MethodReferenceHelperClass.staticFun2(JFunction2<Int, Test> { Test(it) })
|
||||
h.memberFun2(JFunction2<Int, Test> { Test(it) })
|
||||
|
||||
val qualifiedConstructorAnotherClass = JFunction0 { test.Test() }
|
||||
qualifiedConstructorAnotherClass.foo()
|
||||
MethodReferenceHelperClass.staticFun0 { test.Test() }
|
||||
h.memberFun0 { test.Test() }
|
||||
|
||||
val constructorAnotherClassWithoutConstructor = JFunction0 { Test2() }
|
||||
constructorAnotherClassWithoutConstructor.foo()
|
||||
MethodReferenceHelperClass.staticFun0 { Test2() }
|
||||
h.memberFun0 { Test2() }
|
||||
}
|
||||
|
||||
fun testLibraryFunctions() {
|
||||
val memberFunFromClass = JFunction2<String, Int> { it.length }
|
||||
memberFunFromClass.foo("str")
|
||||
|
||||
Thread(Runnable { println() }).start()
|
||||
Runnable { println() }.run()
|
||||
}
|
||||
|
||||
fun testOverloads() {
|
||||
val constructorWithoutParams = JFunction1 { Test.testOverloads() }
|
||||
constructorWithoutParams.foo()
|
||||
MethodReferenceHelperClass.staticFun1 { Test.testOverloads() }
|
||||
h.memberFun1 { Test.testOverloads() }
|
||||
|
||||
val constructorWithParam = JFunction2<Int, String> { Test.testOverloads(it) }
|
||||
constructorWithParam.foo(2)
|
||||
MethodReferenceHelperClass.staticFun2(JFunction2<Int, String> { Test.testOverloads(it) })
|
||||
h.memberFun2(JFunction2<Int, String> { Test.testOverloads(it) })
|
||||
}
|
||||
|
||||
fun testGenericFunctions() {
|
||||
val emptyList = JFunction1<List<String>> { emptyList() }
|
||||
emptyList.foo()
|
||||
MethodReferenceHelperClass.staticFun1(JFunction1<List<String>> { emptyList() })
|
||||
h.memberFun1(JFunction1<List<String>> { emptyList() })
|
||||
}
|
||||
|
||||
fun memberFun(): Int {
|
||||
return 1
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
fun staticFun(): Int {
|
||||
return 1
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
class C {
|
||||
public void foo1(int p1, int p2) {
|
||||
}
|
||||
|
||||
public void foo2(
|
||||
int p1,
|
||||
int p2) {
|
||||
}
|
||||
|
||||
public void foo3(int p1,
|
||||
int p2) {
|
||||
}
|
||||
|
||||
public void foo4(
|
||||
int p1, int p2,
|
||||
int p3, int p4
|
||||
) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
internal class C {
|
||||
fun foo1(p1: Int, p2: Int) {}
|
||||
|
||||
fun foo2(
|
||||
p1: Int,
|
||||
p2: Int) {
|
||||
}
|
||||
|
||||
fun foo3(p1: Int,
|
||||
p2: Int) {
|
||||
}
|
||||
|
||||
fun foo4(
|
||||
p1: Int, p2: Int,
|
||||
p3: Int, p4: Int
|
||||
) {
|
||||
}
|
||||
}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
//method
|
||||
public static void main(String[] args) {}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
@JvmStatic
|
||||
fun main(args: Array<String>) {
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
//file
|
||||
public class A {
|
||||
public static void main(String[] args) {
|
||||
}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
object A {
|
||||
@JvmStatic
|
||||
fun main(args: Array<String>) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
// !forceNotNullTypes: false
|
||||
//file
|
||||
public class A {
|
||||
public static void main(String[] args) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
// !forceNotNullTypes: false
|
||||
object A {
|
||||
@JvmStatic
|
||||
fun main(args: Array<String>) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
//method
|
||||
String main() {}
|
||||
@@ -0,0 +1 @@
|
||||
fun main(): String? {}
|
||||
@@ -0,0 +1,2 @@
|
||||
//method
|
||||
int main() {}
|
||||
@@ -0,0 +1 @@
|
||||
fun main(): Int {}
|
||||
@@ -0,0 +1,2 @@
|
||||
//method
|
||||
boolean main() {}
|
||||
@@ -0,0 +1 @@
|
||||
fun main(): Boolean {}
|
||||
@@ -0,0 +1,2 @@
|
||||
//method
|
||||
boolean isTrue() { return true; }
|
||||
@@ -0,0 +1,2 @@
|
||||
val isTrue: Boolean
|
||||
get() = true
|
||||
@@ -0,0 +1,6 @@
|
||||
public class Foo {
|
||||
private native final void nativeMethod();
|
||||
|
||||
public native final int getBar();
|
||||
public native final void setBar(int bar);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
class Foo {
|
||||
private external fun nativeMethod()
|
||||
|
||||
var bar: Int
|
||||
external get
|
||||
external set
|
||||
}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
//method
|
||||
String getString() { return ""; }
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
val string: String
|
||||
get() = ""
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
//file
|
||||
class A {void a() {}} final class B extends A {void a() {}}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
internal open class A {
|
||||
internal open fun a() {}
|
||||
}
|
||||
|
||||
internal class B : A() {
|
||||
override fun a() {}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
//file
|
||||
class A {
|
||||
void foo() {}
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
void foo() {}
|
||||
}
|
||||
|
||||
class C extends B {
|
||||
void foo() {}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
internal open class A {
|
||||
internal open fun foo() {}
|
||||
}
|
||||
|
||||
internal open class B : A() {
|
||||
override fun foo() {}
|
||||
}
|
||||
|
||||
internal class C : B() {
|
||||
override fun foo() {}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
//file
|
||||
class X {
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return super.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return super.equals(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return super.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object clone() throws CloneNotSupportedException {
|
||||
return super.clone();
|
||||
}
|
||||
}
|
||||
|
||||
class Y extends Thread {
|
||||
@Override
|
||||
protected Object clone() throws CloneNotSupportedException {
|
||||
return super.clone();
|
||||
}
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
internal class X : Cloneable {
|
||||
override fun hashCode(): Int {
|
||||
return super.hashCode()
|
||||
}
|
||||
|
||||
override fun equals(o: Any?): Boolean {
|
||||
return super.equals(o)
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
return super.toString()
|
||||
}
|
||||
|
||||
@Throws(CloneNotSupportedException::class)
|
||||
override fun clone(): Any {
|
||||
return super.clone()
|
||||
}
|
||||
}
|
||||
|
||||
internal class Y : Thread(), Cloneable {
|
||||
@Throws(CloneNotSupportedException::class)
|
||||
override fun clone(): Any {
|
||||
return super.clone()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
//file
|
||||
class Base {}
|
||||
|
||||
class X extends Base {
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return super.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return super.equals(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return super.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object clone() throws CloneNotSupportedException {
|
||||
return super.clone();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
// ERROR: Unresolved reference: clone
|
||||
internal open class Base
|
||||
|
||||
internal class X : Base(), Cloneable {
|
||||
override fun hashCode(): Int {
|
||||
return super.hashCode()
|
||||
}
|
||||
|
||||
override fun equals(o: Any?): Boolean {
|
||||
return super.equals(o)
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
return super.toString()
|
||||
}
|
||||
|
||||
@Throws(CloneNotSupportedException::class)
|
||||
override fun clone(): Any {
|
||||
return super.clone()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
//file
|
||||
class Base {
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return super.equals(o);
|
||||
}
|
||||
}
|
||||
|
||||
class X extends Base {
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return super.equals(o);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
internal open class Base {
|
||||
override fun equals(o: Any?): Boolean {
|
||||
return super.equals(o)
|
||||
}
|
||||
}
|
||||
|
||||
internal class X : Base() {
|
||||
override fun equals(o: Any?): Boolean {
|
||||
return super.equals(o)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
class Base {
|
||||
protected void foo(){}
|
||||
}
|
||||
|
||||
class Derived extends Base {
|
||||
@Override
|
||||
public void foo() {
|
||||
super.foo();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
internal open class Base {
|
||||
protected open fun foo() {}
|
||||
}
|
||||
|
||||
internal class Derived : Base() {
|
||||
public override fun foo() {
|
||||
super.foo()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
//method
|
||||
<U> void putU(U u) {}
|
||||
@@ -0,0 +1 @@
|
||||
fun <U> putU(u: U?) {}
|
||||
@@ -0,0 +1,2 @@
|
||||
//method
|
||||
<U, V, W> void putUVW(U u, V v, W w) {}
|
||||
@@ -0,0 +1 @@
|
||||
fun <U, V, W> putUVW(u: U?, v: V?, w: W?) {}
|
||||
@@ -0,0 +1,6 @@
|
||||
//method
|
||||
int foo(int p1, int p2, int p3) {
|
||||
p1++;
|
||||
if (p2 > 0) p3 = 0;
|
||||
return p1 + p2 + p3;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
fun foo(p1: Int, p2: Int, p3: Int): Int {
|
||||
var p1 = p1
|
||||
var p3 = p3
|
||||
p1++
|
||||
if (p2 > 0) p3 = 0
|
||||
return p1 + p2 + p3
|
||||
}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
//method
|
||||
private void test() {}
|
||||
+1
@@ -0,0 +1 @@
|
||||
private fun test() {}
|
||||
@@ -0,0 +1,2 @@
|
||||
//method
|
||||
protected void test() {}
|
||||
+1
@@ -0,0 +1 @@
|
||||
protected fun test() {}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
//method
|
||||
public void test() {}
|
||||
+1
@@ -0,0 +1 @@
|
||||
fun test() {}
|
||||
@@ -0,0 +1,8 @@
|
||||
class A {
|
||||
synchronized void foo() {
|
||||
bar();
|
||||
}
|
||||
|
||||
void bar() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
internal class A {
|
||||
@Synchronized
|
||||
fun foo() {
|
||||
bar()
|
||||
}
|
||||
|
||||
fun bar() {}
|
||||
}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
//method
|
||||
void foo() throws IOException, SerializationException;
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
@Throws(IOException::class, SerializationException::class)
|
||||
fun foo()
|
||||
@@ -0,0 +1,8 @@
|
||||
//file
|
||||
package demo;
|
||||
|
||||
class Test {
|
||||
void test(Object ... args) {
|
||||
args = new Integer[] {1, 2, 3};
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package demo
|
||||
|
||||
internal class Test {
|
||||
fun test(vararg args: Any?) {
|
||||
var argsx = args
|
||||
args = arrayOf(1, 2, 3)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user