Disable tail-call optimization for suspend functions with Unit return type
if it overrides functions with another return type.
Otherwise, we cannot determine on call site that the function returns Unit
and cannot { POP, PUSH Unit } in order to avoid the situation when callee's
continuation resumes with non-unit result. The observed behavior is that
suspend function, which should return Unit, suddenly returns other value.
#KT-35262: Fixed
This commit is contained in:
+63
-10
@@ -8549,16 +8549,6 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/tailCallOptimizations/tryCatch.kt", "kotlin.coroutines");
|
||||
}
|
||||
|
||||
@TestMetadata("unitFunReturnsNonUnit.kt")
|
||||
public void testUnitFunReturnsNonUnit() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/tailCallOptimizations/unitFunReturnsNonUnit.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("unitFunReturnsNonUnitCallSuspend.kt")
|
||||
public void testUnitFunReturnsNonUnitCallSuspend() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/tailCallOptimizations/unitFunReturnsNonUnitCallSuspend.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("unreachable.kt")
|
||||
public void testUnreachable() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/tailCallOptimizations/unreachable.kt");
|
||||
@@ -8568,6 +8558,69 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
public void testWhenUnit() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/tailCallOptimizations/whenUnit.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/coroutines/tailCallOptimizations/unit")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Unit extends AbstractLightAnalysisModeTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInUnit() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/coroutines/tailCallOptimizations/unit"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true);
|
||||
}
|
||||
|
||||
@TestMetadata("override.kt")
|
||||
public void testOverride() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/tailCallOptimizations/unit/override.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("override2.kt")
|
||||
public void testOverride2() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/tailCallOptimizations/unit/override2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("override3.kt")
|
||||
public void testOverride3() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/tailCallOptimizations/unit/override3.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("override4.kt")
|
||||
public void testOverride4() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/tailCallOptimizations/unit/override4.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("override5.kt")
|
||||
public void testOverride5() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/tailCallOptimizations/unit/override5.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("override6.kt")
|
||||
public void testOverride6() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/tailCallOptimizations/unit/override6.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("overrideCrossinline.kt")
|
||||
public void testOverrideCrossinline() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/tailCallOptimizations/unit/overrideCrossinline.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("overrideOverriden.kt")
|
||||
public void testOverrideOverriden() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/tailCallOptimizations/unit/overrideOverriden.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("reflection.kt")
|
||||
public void testReflection() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/tailCallOptimizations/unit/reflection.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("simple.kt")
|
||||
public void testSimple() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/tailCallOptimizations/unit/simple.kt");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/coroutines/tailOperations")
|
||||
|
||||
Reference in New Issue
Block a user