JVM_IR indy-SAM: KT-45069 box lambda 'Unit' return type if needed
This commit is contained in:
Vendored
+16
@@ -0,0 +1,16 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// SAM_CONVERSIONS: INDY
|
||||
// FILE: intReturnTypeAsNumber.kt
|
||||
|
||||
fun box(): String {
|
||||
val num = Sam { 42 }
|
||||
if (num.get() != 42)
|
||||
return "Failed"
|
||||
return "OK"
|
||||
}
|
||||
|
||||
// FILE: Sam.java
|
||||
public interface Sam {
|
||||
Number get();
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// SAM_CONVERSIONS: INDY
|
||||
// FILE: nothingReturnTypeAsObject.kt
|
||||
|
||||
fun interface IFoo<T> {
|
||||
fun foo(): T
|
||||
}
|
||||
|
||||
fun thr(s: String): Nothing = throw RuntimeException(s)
|
||||
|
||||
fun box(): String {
|
||||
try {
|
||||
Sam(::thr).get("OK")
|
||||
} catch (e: RuntimeException) {
|
||||
return e.message!!
|
||||
}
|
||||
return "Failed"
|
||||
}
|
||||
|
||||
|
||||
// FILE: Sam.java
|
||||
public interface Sam {
|
||||
Object get(String s);
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// SAM_CONVERSIONS: INDY
|
||||
// FILE: nothingReturnTypeAsString.kt
|
||||
|
||||
fun interface IFoo<T> {
|
||||
fun foo(): T
|
||||
}
|
||||
|
||||
fun thr(s: String): Nothing = throw RuntimeException(s)
|
||||
|
||||
fun box(): String {
|
||||
try {
|
||||
Sam(::thr).get("OK")
|
||||
} catch (e: RuntimeException) {
|
||||
return e.message!!
|
||||
}
|
||||
return "Failed"
|
||||
}
|
||||
|
||||
|
||||
// FILE: Sam.java
|
||||
public interface Sam {
|
||||
String get(String s);
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// SAM_CONVERSIONS: INDY
|
||||
// FILE: nullableNothingReturnTypeAsObject.kt
|
||||
|
||||
fun interface IFoo<T> {
|
||||
fun foo(): T
|
||||
}
|
||||
|
||||
var t = "Failed"
|
||||
|
||||
fun test(s: String): Nothing? {
|
||||
t = s
|
||||
return null
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val q = Sam(::test).get("OK")
|
||||
if (q != null)
|
||||
return "Failed: $q"
|
||||
return t
|
||||
}
|
||||
|
||||
|
||||
// FILE: Sam.java
|
||||
public interface Sam {
|
||||
Object get(String s);
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// SAM_CONVERSIONS: INDY
|
||||
// FILE: nullableNothingReturnTypeAsString.kt
|
||||
|
||||
fun interface IFoo<T> {
|
||||
fun foo(): T
|
||||
}
|
||||
|
||||
var t = "Failed"
|
||||
|
||||
fun test(s: String): Nothing? {
|
||||
t = s
|
||||
return null
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val q = Sam(::test).get("OK")
|
||||
if (q != null)
|
||||
return "Failed: $q"
|
||||
return t
|
||||
}
|
||||
|
||||
|
||||
// FILE: Sam.java
|
||||
public interface Sam {
|
||||
String get(String s);
|
||||
}
|
||||
compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/voidReturnTypeAsObject.kt
Vendored
+20
@@ -0,0 +1,20 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// SAM_CONVERSIONS: INDY
|
||||
// FILE: voidReturnTypeAsObject.kt
|
||||
var t = "Failed"
|
||||
|
||||
fun ok(s: String) { t = s }
|
||||
|
||||
fun box(): String {
|
||||
val r = Sam(::ok).get("OK")
|
||||
if (r != Unit) {
|
||||
return "Failed: $r"
|
||||
}
|
||||
return t
|
||||
}
|
||||
|
||||
// FILE: Sam.java
|
||||
public interface Sam {
|
||||
Object get(String s);
|
||||
}
|
||||
Reference in New Issue
Block a user