Minor. Add tests with returning inline class from SAM adapter
This commit is contained in:
+18
@@ -18690,6 +18690,24 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
||||
public void testJavaSam() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/funInterface/javaSam.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("javaSamReturnResult.kt")
|
||||
public void testJavaSamReturnResult() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/funInterface/javaSamReturnResult.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("returnIC.kt")
|
||||
public void testReturnIC() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/funInterface/returnIC.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("returnResult.kt")
|
||||
public void testReturnResult() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/funInterface/returnResult.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// WITH_RUNTIME
|
||||
// FULL_RUNTIME
|
||||
|
||||
// FILE: ResultHandler.java
|
||||
|
||||
import kotlin.Result;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface ResultHandler<T> {
|
||||
Result<T> onResult();
|
||||
}
|
||||
|
||||
// FILE: test.kt
|
||||
|
||||
@Suppress("RESULT_CLASS_IN_RETURN_TYPE")
|
||||
fun doSmth(resultHandler: ResultHandler<Boolean>): Result<Boolean> {
|
||||
return resultHandler.onResult()
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val res = doSmth { Result.success(true) }
|
||||
return if (res.isSuccess) "OK" else "FAIL"
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
// WITH_RUNTIME
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// IGNORE_BACKEND: WASM
|
||||
// IGNORE_BACKEND: JVM
|
||||
|
||||
inline class Result<T>(val isSuccess: Boolean)
|
||||
|
||||
fun interface ResultHandler<T> {
|
||||
fun onResult(): Result<T>
|
||||
}
|
||||
|
||||
fun doSmth(resultHandler: ResultHandler<Boolean>): Result<Boolean> {
|
||||
return resultHandler.onResult()
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
var res = doSmth { Result(true) }
|
||||
return if (res.isSuccess) "OK" else "FAIL"
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
// WITH_RUNTIME
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// IGNORE_BACKEND: JVM
|
||||
// IGNORE_BACKEND: WASM
|
||||
|
||||
fun interface ResultHandler<T> {
|
||||
@Suppress("RESULT_CLASS_IN_RETURN_TYPE")
|
||||
fun onResult(): Result<T>
|
||||
}
|
||||
|
||||
@Suppress("RESULT_CLASS_IN_RETURN_TYPE")
|
||||
fun doSmth(resultHandler: ResultHandler<Boolean>): Result<Boolean> {
|
||||
return resultHandler.onResult()
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
var res = doSmth { Result.success(true) }
|
||||
return if (res.isSuccess) "OK" else "FAIL 1"
|
||||
}
|
||||
+18
@@ -18690,6 +18690,24 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
public void testJavaSam() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/funInterface/javaSam.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("javaSamReturnResult.kt")
|
||||
public void testJavaSamReturnResult() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/funInterface/javaSamReturnResult.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("returnIC.kt")
|
||||
public void testReturnIC() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/funInterface/returnIC.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("returnResult.kt")
|
||||
public void testReturnResult() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/funInterface/returnResult.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
|
||||
+18
@@ -18690,6 +18690,24 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
public void testJavaSam() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/funInterface/javaSam.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("javaSamReturnResult.kt")
|
||||
public void testJavaSamReturnResult() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/funInterface/javaSamReturnResult.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("returnIC.kt")
|
||||
public void testReturnIC() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/funInterface/returnIC.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("returnResult.kt")
|
||||
public void testReturnResult() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/funInterface/returnResult.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
|
||||
+15
@@ -15543,6 +15543,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/funInterface/argumentResult.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("returnResult.kt")
|
||||
public void ignoreReturnResult() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/funInterface/returnResult.kt");
|
||||
}
|
||||
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath);
|
||||
}
|
||||
@@ -15560,6 +15565,16 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
public void testJavaSam() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/funInterface/javaSam.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("javaSamReturnResult.kt")
|
||||
public void testJavaSamReturnResult() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/funInterface/javaSamReturnResult.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("returnIC.kt")
|
||||
public void testReturnIC() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/funInterface/returnIC.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/inlineClasses/functionNameMangling")
|
||||
|
||||
js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java
Generated
+10
@@ -13703,6 +13703,16 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes
|
||||
public void testArgumentResult() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/funInterface/argumentResult.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("returnIC.kt")
|
||||
public void testReturnIC() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/funInterface/returnIC.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("returnResult.kt")
|
||||
public void testReturnResult() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/funInterface/returnResult.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/inlineClasses/functionNameMangling")
|
||||
|
||||
Generated
+10
@@ -13160,6 +13160,16 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
||||
public void testArgumentResult() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/funInterface/argumentResult.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("returnIC.kt")
|
||||
public void testReturnIC() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/funInterface/returnIC.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("returnResult.kt")
|
||||
public void testReturnResult() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/funInterface/returnResult.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/inlineClasses/functionNameMangling")
|
||||
|
||||
Generated
+10
@@ -13225,6 +13225,16 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
public void testArgumentResult() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/funInterface/argumentResult.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("returnIC.kt")
|
||||
public void testReturnIC() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/funInterface/returnIC.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("returnResult.kt")
|
||||
public void testReturnResult() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/funInterface/returnResult.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/inlineClasses/functionNameMangling")
|
||||
|
||||
js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java
Generated
+10
@@ -7406,6 +7406,16 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
|
||||
public void testArgumentResult() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/funInterface/argumentResult.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("returnIC.kt")
|
||||
public void testReturnIC() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/funInterface/returnIC.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("returnResult.kt")
|
||||
public void testReturnResult() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/funInterface/returnResult.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/inlineClasses/functionNameMangling")
|
||||
|
||||
Reference in New Issue
Block a user