Migrate boxAgainstJava tests to multi-file framework
This commit is contained in:
-19
@@ -1,19 +0,0 @@
|
||||
class JavaClass {
|
||||
public interface Super1<T> {
|
||||
Thread call(T t);
|
||||
}
|
||||
|
||||
public interface Super2<T> {
|
||||
T call(String s);
|
||||
}
|
||||
|
||||
public interface Sub extends Super1<String>, Super2<Thread> {
|
||||
Thread call(String s);
|
||||
}
|
||||
|
||||
static void samAdapter(Sub sub) {
|
||||
((Super1) sub).call("");
|
||||
((Super2) sub).call("");
|
||||
sub.call("");
|
||||
}
|
||||
}
|
||||
+24
@@ -1,3 +1,27 @@
|
||||
// FILE: JavaClass.java
|
||||
|
||||
class JavaClass {
|
||||
public interface Super1<T> {
|
||||
Thread call(T t);
|
||||
}
|
||||
|
||||
public interface Super2<T> {
|
||||
T call(String s);
|
||||
}
|
||||
|
||||
public interface Sub extends Super1<String>, Super2<Thread> {
|
||||
Thread call(String s);
|
||||
}
|
||||
|
||||
static void samAdapter(Sub sub) {
|
||||
((Super1) sub).call("");
|
||||
((Super2) sub).call("");
|
||||
sub.call("");
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
fun box(): String? {
|
||||
var s: String?
|
||||
s = "FAIL for function literal"
|
||||
|
||||
-17
@@ -1,17 +0,0 @@
|
||||
// KT-5912
|
||||
class JavaClass<T> {
|
||||
public static interface Action<T> {
|
||||
void call(T t);
|
||||
}
|
||||
|
||||
public static class Some<T> {
|
||||
public Some(T t) {
|
||||
}
|
||||
}
|
||||
|
||||
public static interface OnSubscribe<T> extends Action<Some<T>> {}
|
||||
|
||||
void perform(T t, OnSubscribe<T> subscribe) {
|
||||
subscribe.call(new Some(t));
|
||||
}
|
||||
}
|
||||
+22
@@ -1,3 +1,25 @@
|
||||
// FILE: JavaClass.java
|
||||
|
||||
// KT-5912
|
||||
class JavaClass<T> {
|
||||
public static interface Action<T> {
|
||||
void call(T t);
|
||||
}
|
||||
|
||||
public static class Some<T> {
|
||||
public Some(T t) {
|
||||
}
|
||||
}
|
||||
|
||||
public static interface OnSubscribe<T> extends Action<Some<T>> {}
|
||||
|
||||
void perform(T t, OnSubscribe<T> subscribe) {
|
||||
subscribe.call(new Some(t));
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
// KT-5912
|
||||
fun box(): String {
|
||||
var s = "Failt"
|
||||
|
||||
-3
@@ -1,3 +0,0 @@
|
||||
interface JavaInterface {
|
||||
void run(Runnable r);
|
||||
}
|
||||
+9
-1
@@ -1,3 +1,11 @@
|
||||
// FILE: JavaInterface.java
|
||||
|
||||
interface JavaInterface {
|
||||
void run(Runnable r);
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
class Impl: JavaInterface {
|
||||
override fun run(r: Runnable?) {
|
||||
r?.run()
|
||||
@@ -8,4 +16,4 @@ fun box(): String {
|
||||
var v = "FAIL"
|
||||
Impl().run { v = "OK" }
|
||||
return v
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
import java.util.*;
|
||||
|
||||
class JavaClass {
|
||||
public static void sortIntList(List<Integer> list, Comparator<Integer> comparator) {
|
||||
Collections.sort(list, comparator);
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,15 @@
|
||||
// FILE: JavaClass.java
|
||||
|
||||
import java.util.*;
|
||||
|
||||
class JavaClass {
|
||||
public static void sortIntList(List<Integer> list, Comparator<Integer> comparator) {
|
||||
Collections.sort(list, comparator);
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
import java.util.*
|
||||
|
||||
fun box(): String {
|
||||
@@ -5,4 +17,4 @@ fun box(): String {
|
||||
val expected = ArrayList(Arrays.asList(8, 5, 4, 3, 2, 1))
|
||||
JavaClass.sortIntList(list, { a, b -> b - a })
|
||||
return if (list == expected) "OK" else list.toString()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
class JavaClass {
|
||||
private Runnable r;
|
||||
|
||||
public JavaClass(Runnable r) {
|
||||
this.r = r;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
r.run();
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,21 @@
|
||||
// FILE: JavaClass.java
|
||||
|
||||
class JavaClass {
|
||||
private Runnable r;
|
||||
|
||||
public JavaClass(Runnable r) {
|
||||
this.r = r;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
r.run();
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
fun box(): String {
|
||||
var v = "FAIL"
|
||||
JavaClass { v = "OK" }.run()
|
||||
return v
|
||||
}
|
||||
}
|
||||
|
||||
-3
@@ -1,3 +0,0 @@
|
||||
interface GenericInterface<T> {
|
||||
public T foo(double d, int i, long j, short s);
|
||||
}
|
||||
@@ -1,3 +1,11 @@
|
||||
// FILE: GenericInterface.java
|
||||
|
||||
interface GenericInterface<T> {
|
||||
public T foo(double d, int i, long j, short s);
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
internal fun getInterface(): GenericInterface<String> {
|
||||
return GenericInterface { d, i, j, s ->
|
||||
"OK"
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
import java.io.*;
|
||||
|
||||
class JavaClass {
|
||||
public static String invokeFilter(FileFilter f, File file1, File file2) {
|
||||
return f.accept(file1) + " " + f.accept(file2);
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,15 @@
|
||||
// FILE: JavaClass.java
|
||||
|
||||
import java.io.*;
|
||||
|
||||
class JavaClass {
|
||||
public static String invokeFilter(FileFilter f, File file1, File file2) {
|
||||
return f.accept(file1) + " " + f.accept(file2);
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
import java.io.*
|
||||
|
||||
fun box(): String {
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
|
||||
class JavaClass {
|
||||
public static String foo(Comparator<String> comparator) {
|
||||
return Arrays.toString(comparator.getClass().getGenericInterfaces());
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,16 @@
|
||||
// FILE: JavaClass.java
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
|
||||
class JavaClass {
|
||||
public static String foo(Comparator<String> comparator) {
|
||||
return Arrays.toString(comparator.getClass().getGenericInterfaces());
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
fun box(): String {
|
||||
val supertypes = JavaClass.foo { a, b -> a.compareTo(b) }
|
||||
if (supertypes != "[java.util.Comparator<java.lang.String>]") return "Fail: $supertypes"
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
interface JavaInterface {
|
||||
void foo(Runnable r);
|
||||
}
|
||||
@@ -1,3 +1,11 @@
|
||||
// FILE: JavaInterface.java
|
||||
|
||||
interface JavaInterface {
|
||||
void foo(Runnable r);
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
class Impl: JavaInterface {
|
||||
override fun foo(r: Runnable?) {
|
||||
r?.run()
|
||||
@@ -9,4 +17,4 @@ fun box(): String {
|
||||
if (fooMethods.size != 1) return fooMethods.toString()
|
||||
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
class JavaClass {
|
||||
public void run(Runnable r) {
|
||||
r.run();
|
||||
}
|
||||
}
|
||||
+11
-1
@@ -1,3 +1,13 @@
|
||||
// FILE: JavaClass.java
|
||||
|
||||
class JavaClass {
|
||||
public void run(Runnable r) {
|
||||
r.run();
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
internal class KotlinSubclass: JavaClass() {
|
||||
}
|
||||
|
||||
@@ -5,4 +15,4 @@ fun box(): String {
|
||||
var v = "FAIL"
|
||||
KotlinSubclass().run { v = "OK" }
|
||||
return v
|
||||
}
|
||||
}
|
||||
|
||||
-13
@@ -1,13 +0,0 @@
|
||||
class Super {
|
||||
public String lastCalled = null;
|
||||
|
||||
void foo(Runnable r) {
|
||||
lastCalled = "super";
|
||||
}
|
||||
}
|
||||
|
||||
class Sub extends Super {
|
||||
void foo(kotlin.jvm.functions.Function0<kotlin.Unit> r) {
|
||||
lastCalled = "sub";
|
||||
}
|
||||
}
|
||||
+23
@@ -1,3 +1,26 @@
|
||||
// FILE: Super.java
|
||||
|
||||
class Super {
|
||||
public String lastCalled = null;
|
||||
|
||||
void foo(Runnable r) {
|
||||
lastCalled = "super";
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: Sub.java
|
||||
|
||||
import kotlin.jvm.functions.Function0;
|
||||
import kotlin.Unit;
|
||||
|
||||
class Sub extends Super {
|
||||
void foo(Function0<Unit> r) {
|
||||
lastCalled = "sub";
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
fun box(): String {
|
||||
val sub = Sub()
|
||||
val sup: Super = sub
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
class Super {
|
||||
void safeInvoke(Runnable r) {
|
||||
if (r != null) r.run();
|
||||
}
|
||||
}
|
||||
|
||||
class Sub extends Super {
|
||||
}
|
||||
@@ -1,3 +1,16 @@
|
||||
// FILE: Sub.java
|
||||
|
||||
class Super {
|
||||
void safeInvoke(Runnable r) {
|
||||
if (r != null) r.run();
|
||||
}
|
||||
}
|
||||
|
||||
class Sub extends Super {
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
fun box(): String {
|
||||
var r = "FAIL"
|
||||
val sub = Sub()
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
class JavaClass {
|
||||
private Runnable r;
|
||||
|
||||
public JavaClass(Runnable r) {
|
||||
this.r = r;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
r.run();
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,19 @@
|
||||
// FILE: JavaClass.java
|
||||
|
||||
class JavaClass {
|
||||
private Runnable r;
|
||||
|
||||
public JavaClass(Runnable r) {
|
||||
this.r = r;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
r.run();
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
var status: String = "fail" // global property to avoid issues with accessing closure from local class (KT-4174)
|
||||
|
||||
fun box(): String {
|
||||
@@ -5,4 +21,3 @@ fun box(): String {
|
||||
C().run()
|
||||
return status
|
||||
}
|
||||
|
||||
|
||||
-11
@@ -1,11 +0,0 @@
|
||||
class JavaClass {
|
||||
private Runnable r;
|
||||
|
||||
public JavaClass(Runnable r) {
|
||||
this.r = r;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
r.run();
|
||||
}
|
||||
}
|
||||
+16
@@ -1,3 +1,19 @@
|
||||
// FILE: JavaClass.java
|
||||
|
||||
class JavaClass {
|
||||
private Runnable r;
|
||||
|
||||
public JavaClass(Runnable r) {
|
||||
this.r = r;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
r.run();
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
fun box(): String {
|
||||
var v = "FAIL"
|
||||
val x = object : JavaClass({-> v = "OK"}) {}
|
||||
|
||||
Vendored
-11
@@ -1,11 +0,0 @@
|
||||
class JavaClass {
|
||||
private Runnable r;
|
||||
|
||||
public JavaClass(Runnable r) {
|
||||
this.r = r;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
r.run();
|
||||
}
|
||||
}
|
||||
+16
@@ -1,3 +1,19 @@
|
||||
// FILE: JavaClass.java
|
||||
|
||||
class JavaClass {
|
||||
private Runnable r;
|
||||
|
||||
public JavaClass(Runnable r) {
|
||||
this.r = r;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
r.run();
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
fun box(): String {
|
||||
var v = "FAIL"
|
||||
val f = {-> v = "OK"}
|
||||
|
||||
-6
@@ -1,6 +0,0 @@
|
||||
class JavaClass {
|
||||
public static void run(Runnable r1, Runnable r2) {
|
||||
r1.run();
|
||||
r2.run();
|
||||
}
|
||||
}
|
||||
+12
-1
@@ -1,6 +1,17 @@
|
||||
// FILE: JavaClass.java
|
||||
|
||||
class JavaClass {
|
||||
public static void run(Runnable r1, Runnable r2) {
|
||||
r1.run();
|
||||
r2.run();
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
fun box(): String {
|
||||
var v = "FAIL"
|
||||
val f = { v = "O" }
|
||||
JavaClass.run(f, { v += "K" })
|
||||
return v
|
||||
}
|
||||
}
|
||||
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
import java.util.*;
|
||||
|
||||
class JavaClass {
|
||||
public static void sortIntList(List<Integer> list, Comparator<Integer> comparator) {
|
||||
Collections.sort(list, comparator);
|
||||
}
|
||||
}
|
||||
+13
-1
@@ -1,3 +1,15 @@
|
||||
// FILE: JavaClass.java
|
||||
|
||||
import java.util.*;
|
||||
|
||||
class JavaClass {
|
||||
public static void sortIntList(List<Integer> list, Comparator<Integer> comparator) {
|
||||
Collections.sort(list, comparator);
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
import java.util.*
|
||||
|
||||
fun box(): String {
|
||||
@@ -7,4 +19,4 @@ fun box(): String {
|
||||
val f = { a: Int, b: Int -> b - a }
|
||||
JavaClass.sortIntList(list, f)
|
||||
return if (list == expected) "OK" else list.toString()
|
||||
}
|
||||
}
|
||||
|
||||
-11
@@ -1,11 +0,0 @@
|
||||
class JavaClass {
|
||||
private Runnable r;
|
||||
|
||||
public JavaClass(Runnable r) {
|
||||
this.r = r;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
r.run();
|
||||
}
|
||||
}
|
||||
+17
-1
@@ -1,6 +1,22 @@
|
||||
// FILE: JavaClass.java
|
||||
|
||||
class JavaClass {
|
||||
private Runnable r;
|
||||
|
||||
public JavaClass(Runnable r) {
|
||||
this.r = r;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
r.run();
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
fun box(): String {
|
||||
var v = "FAIL"
|
||||
val f = { v = "OK" }
|
||||
JavaClass(f).run()
|
||||
return v
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
class JavaClass {
|
||||
public static String run(Runnable r) {
|
||||
return r == null ? "OK" : "FAIL";
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,14 @@
|
||||
// FILE: JavaClass.java
|
||||
|
||||
class JavaClass {
|
||||
public static String run(Runnable r) {
|
||||
return r == null ? "OK" : "FAIL";
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
fun box(): String {
|
||||
val f: (() -> Unit)? = null
|
||||
return JavaClass.run(f)!!
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
class JavaClass {
|
||||
public static void run(Runnable r) {
|
||||
r.run();
|
||||
}
|
||||
}
|
||||
+11
-1
@@ -1,6 +1,16 @@
|
||||
// FILE: JavaClass.java
|
||||
|
||||
class JavaClass {
|
||||
public static void run(Runnable r) {
|
||||
r.run();
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
fun box(): String {
|
||||
var v = "FAIL"
|
||||
val f = { v = "OK" }
|
||||
JavaClass.run(f)
|
||||
return v
|
||||
}
|
||||
}
|
||||
|
||||
-40
@@ -1,40 +0,0 @@
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
class Container {
|
||||
@NotNull
|
||||
Value get(Runnable i) {
|
||||
i.run();
|
||||
return new Value();
|
||||
}
|
||||
|
||||
void set(Runnable i, @NotNull Value value) {
|
||||
i.run();
|
||||
}
|
||||
}
|
||||
|
||||
class Value {
|
||||
@NotNull Value plus(Runnable i) {
|
||||
i.run();
|
||||
return this;
|
||||
}
|
||||
|
||||
@NotNull Value minus(Runnable i) {
|
||||
i.run();
|
||||
return this;
|
||||
}
|
||||
|
||||
@NotNull Value times(Runnable i) {
|
||||
i.run();
|
||||
return this;
|
||||
}
|
||||
|
||||
@NotNull Value div(Runnable i) {
|
||||
i.run();
|
||||
return this;
|
||||
}
|
||||
|
||||
@NotNull Value mod(Runnable i) {
|
||||
i.run();
|
||||
return this;
|
||||
}
|
||||
}
|
||||
+65
-22
@@ -1,30 +1,73 @@
|
||||
// FILE: Container.java
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
class Container {
|
||||
@NotNull
|
||||
Value get(Runnable i) {
|
||||
i.run();
|
||||
return new Value();
|
||||
}
|
||||
|
||||
void set(Runnable i, @NotNull Value value) {
|
||||
i.run();
|
||||
}
|
||||
}
|
||||
|
||||
class Value {
|
||||
@NotNull Value plus(Runnable i) {
|
||||
i.run();
|
||||
return this;
|
||||
}
|
||||
|
||||
@NotNull Value minus(Runnable i) {
|
||||
i.run();
|
||||
return this;
|
||||
}
|
||||
|
||||
@NotNull Value times(Runnable i) {
|
||||
i.run();
|
||||
return this;
|
||||
}
|
||||
|
||||
@NotNull Value div(Runnable i) {
|
||||
i.run();
|
||||
return this;
|
||||
}
|
||||
|
||||
@NotNull Value mod(Runnable i) {
|
||||
i.run();
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
fun box(): String {
|
||||
var c = Container()
|
||||
var indexAccess = 0
|
||||
|
||||
// TODO uncomment when KT-3723 is fixed
|
||||
var v1 = "FAIL"
|
||||
c[{ indexAccess++ }] += { v1 = "OK" }
|
||||
if (v1 != "OK") return "plus: $v1"
|
||||
|
||||
//var v1 = "FAIL"
|
||||
//c[{ indexAccess++ }] += { v1 = "OK" }
|
||||
//if (v1 != "OK") return "plus: $v1"
|
||||
//
|
||||
//var v2 = "FAIL"
|
||||
//c[{ indexAccess++ }] -= { v2 = "OK" }
|
||||
//if (v2 != "OK") return "minus: $v2"
|
||||
//
|
||||
//var v3 = "FAIL"
|
||||
//c[{ indexAccess++ }] *= { v3 = "OK" }
|
||||
//if (v3 != "OK") return "times: $v3"
|
||||
//
|
||||
//var v4 = "FAIL"
|
||||
//c[{ indexAccess++ }] /= { v4 = "OK" }
|
||||
//if (v4 != "OK") return "div: $v4"
|
||||
//
|
||||
//var v5 = "FAIL"
|
||||
//c[{ indexAccess++ }] %= { v5 = "OK" }
|
||||
//if (v5 != "OK") return "mod: $v5"
|
||||
//
|
||||
//if (indexAccess != 10) return indexAccess
|
||||
var v2 = "FAIL"
|
||||
c[{ indexAccess++ }] -= { v2 = "OK" }
|
||||
if (v2 != "OK") return "minus: $v2"
|
||||
|
||||
var v3 = "FAIL"
|
||||
c[{ indexAccess++ }] *= { v3 = "OK" }
|
||||
if (v3 != "OK") return "times: $v3"
|
||||
|
||||
var v4 = "FAIL"
|
||||
c[{ indexAccess++ }] /= { v4 = "OK" }
|
||||
if (v4 != "OK") return "div: $v4"
|
||||
|
||||
var v5 = "FAIL"
|
||||
c[{ indexAccess++ }] %= { v5 = "OK" }
|
||||
if (v5 != "OK") return "mod: $v5"
|
||||
|
||||
if (indexAccess != 10) return "Fail: $indexAccess"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
Vendored
-21
@@ -1,21 +0,0 @@
|
||||
class JavaClass {
|
||||
void plusAssign(Runnable i) {
|
||||
i.run();
|
||||
}
|
||||
|
||||
void minusAssign(Runnable i) {
|
||||
i.run();
|
||||
}
|
||||
|
||||
void timesAssign(Runnable i) {
|
||||
i.run();
|
||||
}
|
||||
|
||||
void divAssign(Runnable i) {
|
||||
i.run();
|
||||
}
|
||||
|
||||
void modAssign(Runnable i) {
|
||||
i.run();
|
||||
}
|
||||
}
|
||||
+26
@@ -1,3 +1,29 @@
|
||||
// FILE: JavaClass.java
|
||||
|
||||
class JavaClass {
|
||||
void plusAssign(Runnable i) {
|
||||
i.run();
|
||||
}
|
||||
|
||||
void minusAssign(Runnable i) {
|
||||
i.run();
|
||||
}
|
||||
|
||||
void timesAssign(Runnable i) {
|
||||
i.run();
|
||||
}
|
||||
|
||||
void divAssign(Runnable i) {
|
||||
i.run();
|
||||
}
|
||||
|
||||
void modAssign(Runnable i) {
|
||||
i.run();
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
fun box(): String {
|
||||
val obj = JavaClass()
|
||||
|
||||
|
||||
-28
@@ -1,28 +0,0 @@
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
class JavaClass {
|
||||
@NotNull JavaClass plus(Runnable i) {
|
||||
i.run();
|
||||
return this;
|
||||
}
|
||||
|
||||
@NotNull JavaClass minus(Runnable i) {
|
||||
i.run();
|
||||
return this;
|
||||
}
|
||||
|
||||
@NotNull JavaClass times(Runnable i) {
|
||||
i.run();
|
||||
return this;
|
||||
}
|
||||
|
||||
@NotNull JavaClass div(Runnable i) {
|
||||
i.run();
|
||||
return this;
|
||||
}
|
||||
|
||||
@NotNull JavaClass mod(Runnable i) {
|
||||
i.run();
|
||||
return this;
|
||||
}
|
||||
}
|
||||
+33
@@ -1,3 +1,36 @@
|
||||
// FILE: JavaClass.java
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
class JavaClass {
|
||||
@NotNull JavaClass plus(Runnable i) {
|
||||
i.run();
|
||||
return this;
|
||||
}
|
||||
|
||||
@NotNull JavaClass minus(Runnable i) {
|
||||
i.run();
|
||||
return this;
|
||||
}
|
||||
|
||||
@NotNull JavaClass times(Runnable i) {
|
||||
i.run();
|
||||
return this;
|
||||
}
|
||||
|
||||
@NotNull JavaClass div(Runnable i) {
|
||||
i.run();
|
||||
return this;
|
||||
}
|
||||
|
||||
@NotNull JavaClass mod(Runnable i) {
|
||||
i.run();
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
fun box(): String {
|
||||
var obj = JavaClass()
|
||||
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
class JavaClass {
|
||||
JavaClass plus(Runnable i) {
|
||||
i.run();
|
||||
return this;
|
||||
}
|
||||
|
||||
JavaClass minus(Runnable i) {
|
||||
i.run();
|
||||
return this;
|
||||
}
|
||||
|
||||
JavaClass times(Runnable i) {
|
||||
i.run();
|
||||
return this;
|
||||
}
|
||||
|
||||
JavaClass div(Runnable i) {
|
||||
i.run();
|
||||
return this;
|
||||
}
|
||||
|
||||
JavaClass mod(Runnable i) {
|
||||
i.run();
|
||||
return this;
|
||||
}
|
||||
|
||||
JavaClass rangeTo(Runnable i) {
|
||||
i.run();
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,39 @@
|
||||
// FILE: JavaClass.java
|
||||
|
||||
class JavaClass {
|
||||
JavaClass plus(Runnable i) {
|
||||
i.run();
|
||||
return this;
|
||||
}
|
||||
|
||||
JavaClass minus(Runnable i) {
|
||||
i.run();
|
||||
return this;
|
||||
}
|
||||
|
||||
JavaClass times(Runnable i) {
|
||||
i.run();
|
||||
return this;
|
||||
}
|
||||
|
||||
JavaClass div(Runnable i) {
|
||||
i.run();
|
||||
return this;
|
||||
}
|
||||
|
||||
JavaClass mod(Runnable i) {
|
||||
i.run();
|
||||
return this;
|
||||
}
|
||||
|
||||
JavaClass rangeTo(Runnable i) {
|
||||
i.run();
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
fun box(): String {
|
||||
val obj = JavaClass()
|
||||
|
||||
|
||||
-6
@@ -1,6 +0,0 @@
|
||||
class JavaClass {
|
||||
int compareTo(Runnable i) {
|
||||
i.run();
|
||||
return 239;
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,14 @@
|
||||
// FILE: JavaClass.java
|
||||
|
||||
class JavaClass {
|
||||
int compareTo(Runnable i) {
|
||||
i.run();
|
||||
return 239;
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
fun box(): String {
|
||||
val obj = JavaClass()
|
||||
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
class JavaClass {
|
||||
boolean contains(Runnable i) {
|
||||
i.run();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,14 @@
|
||||
// FILE: JavaClass.java
|
||||
|
||||
class JavaClass {
|
||||
boolean contains(Runnable i) {
|
||||
i.run();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
fun box(): String {
|
||||
val obj = JavaClass()
|
||||
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
class JavaClass {
|
||||
int get(Runnable i) {
|
||||
i.run();
|
||||
return 239;
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,14 @@
|
||||
// FILE: JavaClass.java
|
||||
|
||||
class JavaClass {
|
||||
int get(Runnable i) {
|
||||
i.run();
|
||||
return 239;
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
fun box(): String {
|
||||
val obj = JavaClass()
|
||||
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
class JavaClass {
|
||||
void invoke(Runnable i) {
|
||||
i.run();
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,13 @@
|
||||
// FILE: JavaClass.java
|
||||
|
||||
class JavaClass {
|
||||
void invoke(Runnable i) {
|
||||
i.run();
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
fun box(): String {
|
||||
val obj = JavaClass()
|
||||
|
||||
|
||||
-13
@@ -1,13 +0,0 @@
|
||||
class JavaClass {
|
||||
int get(Runnable i1, Runnable i2) {
|
||||
i1.run();
|
||||
i2.run();
|
||||
return 239;
|
||||
}
|
||||
|
||||
void set(Runnable i1, Runnable i2, Runnable value) {
|
||||
i1.run();
|
||||
i2.run();
|
||||
value.run();
|
||||
}
|
||||
}
|
||||
+18
@@ -1,3 +1,21 @@
|
||||
// FILE: JavaClass.java
|
||||
|
||||
class JavaClass {
|
||||
int get(Runnable i1, Runnable i2) {
|
||||
i1.run();
|
||||
i2.run();
|
||||
return 239;
|
||||
}
|
||||
|
||||
void set(Runnable i1, Runnable i2, Runnable value) {
|
||||
i1.run();
|
||||
i2.run();
|
||||
value.run();
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
fun box(): String {
|
||||
val obj = JavaClass()
|
||||
|
||||
|
||||
-6
@@ -1,6 +0,0 @@
|
||||
class JavaClass {
|
||||
void invoke(Runnable p1, Runnable p2) {
|
||||
p1.run();
|
||||
p2.run();
|
||||
}
|
||||
}
|
||||
+11
@@ -1,3 +1,14 @@
|
||||
// FILE: JavaClass.java
|
||||
|
||||
class JavaClass {
|
||||
void invoke(Runnable p1, Runnable p2) {
|
||||
p1.run();
|
||||
p2.run();
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
fun box(): String {
|
||||
val obj = JavaClass()
|
||||
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
class JavaClass {
|
||||
void set(Runnable i, Runnable value) {
|
||||
i.run();
|
||||
value.run();
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,14 @@
|
||||
// FILE: JavaClass.java
|
||||
|
||||
class JavaClass {
|
||||
void set(Runnable i, Runnable value) {
|
||||
i.run();
|
||||
value.run();
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
fun box(): String {
|
||||
val obj = JavaClass()
|
||||
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
class JavaClass<T> {
|
||||
protected void execute(T t, Runnable r) {
|
||||
r.run();
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,13 @@
|
||||
// FILE: JavaClass.java
|
||||
|
||||
class JavaClass<T> {
|
||||
protected void execute(T t, Runnable r) {
|
||||
r.run();
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
internal class KotlinClass : JavaClass<String>() {
|
||||
fun doIt(): String {
|
||||
var result = ""
|
||||
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
import java.util.*;
|
||||
|
||||
class JavaClass {
|
||||
public static String findMaxAndInvokeCallback(Comparator<String> comparator, String a, String b, Runnable afterRunnable) {
|
||||
int compare = comparator.compare(a, b);
|
||||
afterRunnable.run();
|
||||
return compare > 0 ? a : b;
|
||||
}
|
||||
}
|
||||
+14
@@ -1,3 +1,17 @@
|
||||
// FILE: JavaClass.java
|
||||
|
||||
import java.util.*;
|
||||
|
||||
class JavaClass {
|
||||
public static String findMaxAndInvokeCallback(Comparator<String> comparator, String a, String b, Runnable afterRunnable) {
|
||||
int compare = comparator.compare(a, b);
|
||||
afterRunnable.run();
|
||||
return compare > 0 ? a : b;
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
fun box(): String {
|
||||
var v = "FAIL"
|
||||
val max = JavaClass.findMaxAndInvokeCallback({ a, b -> a.length - b.length }, "foo", "kotlin", { v = "OK" })
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
class JavaClass {
|
||||
public static void run(Runnable r) {
|
||||
r.run();
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,15 @@
|
||||
// FILE: JavaClass.java
|
||||
|
||||
class JavaClass {
|
||||
public static void run(Runnable r) {
|
||||
r.run();
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
fun box(): String {
|
||||
var v = "FAIL"
|
||||
JavaClass.run { v = "OK" }
|
||||
return v
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
class JavaClass {
|
||||
JavaClass(Runnable r) {
|
||||
if (r != null) r.run();
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,13 @@
|
||||
// FILE: JavaClass.java
|
||||
|
||||
class JavaClass {
|
||||
JavaClass(Runnable r) {
|
||||
if (r != null) r.run();
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
internal class KotlinClass(): JavaClass(null) {
|
||||
}
|
||||
|
||||
|
||||
-5
@@ -1,5 +0,0 @@
|
||||
class JavaClass {
|
||||
JavaClass(Runnable r) {
|
||||
if (r != null) r.run();
|
||||
}
|
||||
}
|
||||
+10
@@ -1,3 +1,13 @@
|
||||
// FILE: JavaClass.java
|
||||
|
||||
class JavaClass {
|
||||
JavaClass(Runnable r) {
|
||||
if (r != null) r.run();
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
var status: String = "fail" // global property to avoid issues with accessing closure from local class (KT-4174)
|
||||
|
||||
internal class KotlinClass(): JavaClass({status="OK"}) {
|
||||
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
import java.util.*;
|
||||
|
||||
class WeirdComparator<T> {
|
||||
public T max(Comparator<T> comparator, T value1, T value2) {
|
||||
return comparator.compare(value1, value2) > 0 ? value1 : value2;
|
||||
}
|
||||
}
|
||||
+12
@@ -1,3 +1,15 @@
|
||||
// FILE: WeirdComparator.java
|
||||
|
||||
import java.util.*;
|
||||
|
||||
class WeirdComparator<T> {
|
||||
public T max(Comparator<T> comparator, T value1, T value2) {
|
||||
return comparator.compare(value1, value2) > 0 ? value1 : value2;
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
fun box(): String {
|
||||
val wc = WeirdComparator<String>()
|
||||
val result = wc.max({ a, b -> a.length - b.length }, "java", "kotlin")
|
||||
|
||||
-11
@@ -1,11 +0,0 @@
|
||||
import java.util.*;
|
||||
|
||||
class WeirdComparator {
|
||||
public static <T> T max(Comparator<T> comparator, T value1, T value2) {
|
||||
return comparator.compare(value1, value2) > 0 ? value1 : value2;
|
||||
}
|
||||
|
||||
public static <T extends CharSequence> T max2(Comparator<T> comparator, T value1, T value2) {
|
||||
return comparator.compare(value1, value2) > 0 ? value1 : value2;
|
||||
}
|
||||
}
|
||||
+16
@@ -1,3 +1,19 @@
|
||||
// FILE: WeirdComparator.java
|
||||
|
||||
import java.util.*;
|
||||
|
||||
class WeirdComparator {
|
||||
public static <T> T max(Comparator<T> comparator, T value1, T value2) {
|
||||
return comparator.compare(value1, value2) > 0 ? value1 : value2;
|
||||
}
|
||||
|
||||
public static <T extends CharSequence> T max2(Comparator<T> comparator, T value1, T value2) {
|
||||
return comparator.compare(value1, value2) > 0 ? value1 : value2;
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
fun box(): String {
|
||||
val result = WeirdComparator.max<String>({ a, b -> a.length - b.length }, "java", "kotlin")
|
||||
if (result != "kotlin") return "Wrong: $result"
|
||||
|
||||
-13
@@ -1,13 +0,0 @@
|
||||
import java.util.*;
|
||||
|
||||
class WeirdComparator<T> {
|
||||
public Inner createInner() {
|
||||
return new Inner();
|
||||
}
|
||||
|
||||
public class Inner {
|
||||
public T max(Comparator<T> comparator, T value1, T value2) {
|
||||
return comparator.compare(value1, value2) > 0 ? value1 : value2;
|
||||
}
|
||||
}
|
||||
}
|
||||
+18
@@ -1,3 +1,21 @@
|
||||
// FILE: WeirdComparator.java
|
||||
|
||||
import java.util.*;
|
||||
|
||||
class WeirdComparator<T> {
|
||||
public Inner createInner() {
|
||||
return new Inner();
|
||||
}
|
||||
|
||||
public class Inner {
|
||||
public T max(Comparator<T> comparator, T value1, T value2) {
|
||||
return comparator.compare(value1, value2) > 0 ? value1 : value2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
fun box(): String {
|
||||
val wc = WeirdComparator<String>().createInner()!!
|
||||
val result = wc.max({ a, b -> a.length - b.length }, "java", "kotlin")
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
class Custom {
|
||||
public interface Runnable {
|
||||
void run2();
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,17 @@
|
||||
// FILE: Custom.java
|
||||
|
||||
class Custom {
|
||||
public interface Runnable {
|
||||
void run2();
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
fun box(): String {
|
||||
val f = { }
|
||||
val class1 = Runnable(f).javaClass
|
||||
val class2 = Custom.Runnable(f).javaClass
|
||||
|
||||
return if (class1 != class2) "OK" else "Same class: $class1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
interface Base<T> {
|
||||
void call(T t);
|
||||
}
|
||||
|
||||
interface Derived extends Base<String> {
|
||||
}
|
||||
@@ -1,3 +1,16 @@
|
||||
// FILE: Base.java
|
||||
|
||||
interface Base<T> {
|
||||
void call(T t);
|
||||
}
|
||||
|
||||
// FILE: Derived.java
|
||||
|
||||
interface Derived extends Base<String> {
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
fun box(): String {
|
||||
Base<String>{}.call("")
|
||||
Derived{}.call("")
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
class ParamBase<T> {}
|
||||
|
||||
interface F<T> extends FBase<ParamBase<? extends T>> {
|
||||
}
|
||||
|
||||
interface FBase<T> {
|
||||
void call(T t);
|
||||
}
|
||||
@@ -1,3 +1,20 @@
|
||||
// FILE: ParamBase.java
|
||||
|
||||
class ParamBase<T> {}
|
||||
|
||||
// FILE: F.java
|
||||
|
||||
interface F<T> extends FBase<ParamBase<? extends T>> {
|
||||
}
|
||||
|
||||
// FILE: FBase.java
|
||||
|
||||
interface FBase<T> {
|
||||
void call(T t);
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
fun box(): String {
|
||||
F<ParamBase<Int>>({}).call(ParamBase())
|
||||
return "OK"
|
||||
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
class JavaClass {
|
||||
interface Computable<T> {
|
||||
T compute();
|
||||
}
|
||||
|
||||
static <T> T compute(Computable<T> computable) {
|
||||
return computable.compute();
|
||||
}
|
||||
}
|
||||
+14
@@ -1,3 +1,17 @@
|
||||
// FILE: JavaClass.java
|
||||
|
||||
class JavaClass {
|
||||
interface Computable<T> {
|
||||
T compute();
|
||||
}
|
||||
|
||||
static <T> T compute(Computable<T> computable) {
|
||||
return computable.compute();
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
import java.util.Arrays
|
||||
|
||||
fun box(): String {
|
||||
|
||||
Reference in New Issue
Block a user