KT-38450 Add functional interface converter to the NJ2K

- Enable custom compiler options for
`AbstractNewJavaToKotlinConverterSingleFileTest`
- ^KT-38450 Fixed
This commit is contained in:
Roman Golyshev
2020-05-25 11:03:31 +03:00
committed by Roman Golyshev
parent 50fc9d3692
commit 4436142f00
24 changed files with 224 additions and 13 deletions
@@ -0,0 +1,6 @@
// RUNTIME_WITH_FULL_JDK
@FunctionalInterface
public interface MyRunnable {
int getResult();
}
@@ -0,0 +1,4 @@
// RUNTIME_WITH_FULL_JDK
fun interface MyRunnable {
fun getResult(): Int
}
@@ -0,0 +1,10 @@
// RUNTIME_WITH_FULL_JDK
@FunctionalInterface
public interface MyRunnable {
int getResult();
default int getDoubleResult() {
return getResult() * 2;
}
}
@@ -0,0 +1,6 @@
// RUNTIME_WITH_FULL_JDK
fun interface MyRunnable {
fun getResult(): Int
val doubleResult: Int
get() = getResult() * 2
}
@@ -0,0 +1,5 @@
// RUNTIME_WITH_FULL_JDK
public interface MyRunnable {
int getResult();
}
@@ -0,0 +1,4 @@
// RUNTIME_WITH_FULL_JDK
interface MyRunnable {
val result: Int
}
@@ -0,0 +1,18 @@
// RUNTIME_WITH_FULL_JDK
// we intentionally do not convert interface to Kotlin fun interface
// if it inherits from some other interface, because it is hard to deal
// with default methods which were already converted to properties
// (and in kotlin fun interface cannot have abstract property)
public interface MyRunnableBase {
default int getValue() {
return 0;
}
}
@FunctionalInterface
public interface MyRunnable extends MyRunnableBase {
@Override
int getValue();
}
@@ -0,0 +1,14 @@
// RUNTIME_WITH_FULL_JDK
// we intentionally do not convert interface to Kotlin fun interface
// if it inherits from some other interface, because it is hard to deal
// with default methods which were already converted to properties
// (and in kotlin fun interface cannot have abstract property)
interface MyRunnableBase {
val value: Int
get() = 0
}
@FunctionalInterface
interface MyRunnable : MyRunnableBase {
abstract override val value: Int
}
@@ -0,0 +1,6 @@
// RUNTIME_WITH_FULL_JDK
@FunctionalInterface
public interface MyRunnable {
void run();
}
@@ -0,0 +1,4 @@
// RUNTIME_WITH_FULL_JDK
fun interface MyRunnable {
fun run()
}
@@ -0,0 +1,3 @@
public interface MyRunnable {
void run();
}
@@ -0,0 +1,3 @@
interface MyRunnable {
fun run()
}
@@ -0,0 +1,7 @@
// RUNTIME_WITH_FULL_JDK
// COMPILER_ARGUMENTS: -XXLanguage:-FunctionalInterfaceConversion
@FunctionalInterface
public interface MyRunnable {
void run();
}
@@ -0,0 +1,6 @@
// RUNTIME_WITH_FULL_JDK
// COMPILER_ARGUMENTS: -XXLanguage:-FunctionalInterfaceConversion
@FunctionalInterface
interface MyRunnable {
fun run()
}
@@ -0,0 +1,6 @@
// RUNTIME_WITH_FULL_JDK
@FunctionalInterface
public interface MyRunnable {
<T> void process(T t);
}
@@ -0,0 +1,5 @@
// RUNTIME_WITH_FULL_JDK
@FunctionalInterface
interface MyRunnable {
fun <T> process(t: T)
}