mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-09 00:21:47 +00:00
If new inference is enabled only for IDE analysis, then this feature will be disabled to reduce difference between new and old inference, but if new inference is enabled in the compiler, then this feature will be enabled too to preserve behavior of new inference for compilation #KT-32175 Fixed #KT-32143 Fixed #KT-32123 Fixed #KT-32230 Fixed
78 lines
1.3 KiB
Kotlin
Vendored
78 lines
1.3 KiB
Kotlin
Vendored
// !LANGUAGE: +NewInference
|
|
// TARGET_BACKEND: JVM
|
|
|
|
// FILE: example/Hello.java
|
|
|
|
package example;
|
|
|
|
@FunctionalInterface
|
|
public interface Hello<A> {
|
|
void invoke(A a);
|
|
}
|
|
|
|
// FILE: example/SomeJavaClass.java
|
|
package example;
|
|
|
|
public class SomeJavaClass<A> {
|
|
public void someFunction(Hello<A> hello) {
|
|
((Hello)hello).invoke("OK");
|
|
}
|
|
|
|
public SomeJavaClass<A> plus(Hello<A> hello) {
|
|
((Hello)hello).invoke("OK");
|
|
return this;
|
|
}
|
|
|
|
public void get(Hello<A> hello) {
|
|
((Hello)hello).invoke("OK");
|
|
}
|
|
|
|
public void set(int i, Hello<A> hello) {
|
|
((Hello)hello).invoke("OK");
|
|
}
|
|
}
|
|
|
|
// FILE: main.kt
|
|
import example.SomeJavaClass
|
|
|
|
fun box(): String {
|
|
var a: SomeJavaClass<out String> = SomeJavaClass()
|
|
|
|
var result = "fail"
|
|
|
|
a.someFunction {
|
|
result = it
|
|
}
|
|
|
|
if (result != "OK") return "fail 1: $result"
|
|
result = "fail"
|
|
|
|
a + {
|
|
result = it
|
|
}
|
|
|
|
if (result != "OK") return "fail 2: $result"
|
|
result = "fail"
|
|
|
|
a[{
|
|
result = it
|
|
}]
|
|
|
|
if (result != "OK") return "fail 3: $result"
|
|
|
|
result = "fail"
|
|
|
|
a += {
|
|
result = it
|
|
}
|
|
|
|
if (result != "OK") return "fail 4: $result"
|
|
|
|
result = "fail"
|
|
|
|
a[0] = { result = it }
|
|
|
|
if (result != "OK") return "fail 5: $result"
|
|
|
|
return "OK"
|
|
} |