KT-27524 Don't box (some) inline classes in suspend fun return

If an inline class is mapped to a reference type (or an array), it's Ok
to treat JVM view on a suspend function as returning a value of
corresponding inline class (although in reality it returns 'Any?'
because of COROUTINE_SUSPENDED).
This commit is contained in:
Dmitry Petrov
2020-03-26 20:37:29 +03:00
parent d8bc29e6c6
commit 042424d599
22 changed files with 1220 additions and 7 deletions
@@ -1472,6 +1472,34 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest {
}
}
@TestMetadata("compiler/testData/codegen/bytecodeText/coroutines/inlineClasses")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class InlineClasses extends AbstractBytecodeTextTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath);
}
public void testAllFilesPresentInInlineClasses() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/bytecodeText/coroutines/inlineClasses"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true);
}
@TestMetadata("inlineClassBoxingInSuspendFunReturn_Primitive.kt")
public void testInlineClassBoxingInSuspendFunReturn_Primitive() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/coroutines/inlineClasses/inlineClassBoxingInSuspendFunReturn_Primitive.kt");
}
@TestMetadata("noInlineClassBoxingInSuspendFunReturn_Any.kt")
public void testNoInlineClassBoxingInSuspendFunReturn_Any() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/coroutines/inlineClasses/noInlineClassBoxingInSuspendFunReturn_Any.kt");
}
@TestMetadata("noInlineClassBoxingInSuspendFunReturn_InlineAny.kt")
public void testNoInlineClassBoxingInSuspendFunReturn_InlineAny() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/coroutines/inlineClasses/noInlineClassBoxingInSuspendFunReturn_InlineAny.kt");
}
}
@TestMetadata("compiler/testData/codegen/bytecodeText/coroutines/intLikeVarSpilling")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)