JVM_IR indy-SAM: function reference to Java interface

This commit is contained in:
Dmitry Petrov
2021-02-18 13:57:40 +03:00
parent 357a7907a3
commit c629ba5a3c
39 changed files with 1005 additions and 135 deletions
@@ -0,0 +1,29 @@
// TARGET_BACKEND: JVM
// JVM_TARGET: 1.8
// SAM_CONVERSIONS: INDY
// FILE: enhancedNullability.kt
fun interface IGetInt {
fun get(x: Int): Int
}
// fun interface IGetIntMix0 : IGetInt, Sam
// ^ Error: [FUN_INTERFACE_WRONG_COUNT_OF_ABSTRACT_MEMBERS] Fun interfaces must have exactly one abstract method
fun interface IGetIntMix1 : IGetInt, Sam {
override fun get(x: Int): Int
}
fun box(): String {
val t1 = IGetIntMix1 { it: Int -> it * 2 }.get(21)
if (t1 != 42)
return "Failed: t1=$t1"
return "OK"
}
// FILE: Sam.java
import org.jetbrains.annotations.*;
public interface Sam {
@NotNull Integer get(@NotNull Integer arg);
}