Files
kotlin-fork/compiler/testData/diagnostics/testsWithStdLib/DeprecatedFunctionClasses.kt
T
Alexander Udalov d14e5b8a72 Restore and deprecate Function{n}/ExtensionFunction{n} classes for easier migration
Users' Java code will not break in common cases (when passing functions to
Kotlin), and deprecation warnings will be reported.

Provide an inspection with a quick fix which allows to replace deprecated
function class usages to the new classes. Include this fix to the "code
cleanup" action
2015-05-28 01:20:05 +03:00

36 lines
899 B
Kotlin
Vendored

// FILE: J.java
import kotlin.ExtensionFunction0;
import kotlin.ExtensionFunction1;
import kotlin.Function0;
import kotlin.Function1;
import kotlin.Unit;
public class J {
public static void f1(Function0<Unit> f) {
f.invoke();
}
public static void f2(Function1<String, String> f) {
f.invoke("");
}
public static void ef1(ExtensionFunction1<Integer, Integer, Integer> ef) {
ef.invoke(42, -42);
}
public static ExtensionFunction0<String, Unit> ef2() {
return null;
}
}
// FILE: K.kt
fun foo() = J.<!JAVA_METHOD_USES_DEPRECATED_FUNCTION_CLASS!>f1 { }<!>
fun bar() = J.<!JAVA_METHOD_USES_DEPRECATED_FUNCTION_CLASS!>f2 { it }<!>
fun baz() = J.<!JAVA_METHOD_USES_DEPRECATED_FUNCTION_CLASS!>ef1 <!EXPECTED_PARAMETERS_NUMBER_MISMATCH!>{<!> <!NO_THIS!>this<!> }<!>
fun quux() = J.<!JAVA_METHOD_USES_DEPRECATED_FUNCTION_CLASS!>ef2()<!>