J2K: Convert usages of kotlin functions from library correctly
#KT-6115 Fixed
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
package demo;
|
||||
|
||||
import kotlin.Lazy;
|
||||
import kotlin.LazyKt;
|
||||
import kotlin.LazyThreadSafetyMode;
|
||||
import kotlin.collections.CollectionsKt;
|
||||
import kotlin.jvm.functions.Function0;
|
||||
import kotlin.jvm.functions.Function1;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class TestJava {
|
||||
public static void main(String[] args) {
|
||||
List<String> x = new ArrayList<String>();
|
||||
CollectionsKt.filter(x, new Function1<String, Boolean>() {
|
||||
@Override
|
||||
public Boolean invoke(String o) {
|
||||
return o.equals("a");
|
||||
}
|
||||
});
|
||||
Lazy<String> lazy = LazyKt.lazy(LazyThreadSafetyMode.NONE, new Function0<String>() {
|
||||
@Override
|
||||
public String invoke() {
|
||||
return "aaa";
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void f(Function1<String, Unit> result) {
|
||||
result.invoke("a")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package demo
|
||||
|
||||
import java.util.ArrayList
|
||||
|
||||
class TestJava {
|
||||
|
||||
fun f(result: Function1<String, Unit>) {
|
||||
result.invoke("a")
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic fun main(args: Array<String>) {
|
||||
val x = ArrayList<String>()
|
||||
x.filter { o -> o == "a" }
|
||||
val lazy = lazy(LazyThreadSafetyMode.NONE) { "aaa" }
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user