Move tailrecPhase before defaultArgumentStubPhase
So that default values can be copied to the recursive call sites.
This commit is contained in:
committed by
max-kammerer
parent
6addb24e4b
commit
bdcd6f73b1
@@ -112,6 +112,7 @@ val jvmPhases = namedIrFilePhase<JvmBackendContext>(
|
||||
propertiesPhase then
|
||||
renameFieldsPhase then
|
||||
annotationPhase then
|
||||
tailrecPhase then
|
||||
|
||||
defaultArgumentStubPhase then
|
||||
|
||||
@@ -145,7 +146,6 @@ val jvmPhases = namedIrFilePhase<JvmBackendContext>(
|
||||
jvmStaticAnnotationPhase then
|
||||
staticDefaultFunctionPhase then
|
||||
|
||||
tailrecPhase then
|
||||
toArrayPhase then
|
||||
flattenStringConcatenationPhase then
|
||||
foldConstantLoweringPhase then
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// DONT_RUN_GENERATED_CODE: JS
|
||||
|
||||
tailrec fun test(x : Int = 0, e : Any = "a") {
|
||||
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// DONT_RUN_GENERATED_CODE: JS
|
||||
|
||||
tailrec fun test(x : Int = 0, e : Any = "a") {
|
||||
if (x < 100000 && !e.equals("a")) {
|
||||
throw IllegalArgumentException()
|
||||
}
|
||||
if (x > 0) {
|
||||
test(x - 1)
|
||||
}
|
||||
}
|
||||
|
||||
fun box() : String {
|
||||
test(100000, "b")
|
||||
return "OK"
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
package
|
||||
|
||||
public fun box(): kotlin.String
|
||||
public tailrec fun test(/*0*/ x: kotlin.Int = ..., /*1*/ e: kotlin.Any = ...): kotlin.Unit
|
||||
Vendored
+34
@@ -0,0 +1,34 @@
|
||||
// DONT_RUN_GENERATED_CODE: JS
|
||||
// IGNORE_BACKEND: JVM
|
||||
|
||||
var counter = 0
|
||||
fun inc() = counter++
|
||||
|
||||
tailrec fun test(x: Int = 0, y: Int = inc(), z: Int = inc()) {
|
||||
if (x * 2 != y || z - y != 1)
|
||||
throw IllegalArgumentException("x=$x y=$y z=$z")
|
||||
|
||||
if (x < 100000)
|
||||
test(x + 1)
|
||||
}
|
||||
|
||||
fun box() : String {
|
||||
test()
|
||||
|
||||
counter = 4
|
||||
test(x = 1, y = 2, z = 3)
|
||||
|
||||
counter = 0
|
||||
test(-1, -2, -1)
|
||||
|
||||
counter = 3
|
||||
test(1, 2)
|
||||
|
||||
counter = 1
|
||||
test(y = 0)
|
||||
|
||||
counter = 2
|
||||
test(x = 1)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
package
|
||||
|
||||
public var counter: kotlin.Int
|
||||
public fun box(): kotlin.String
|
||||
public fun inc(): kotlin.Int
|
||||
public tailrec fun test(/*0*/ x: kotlin.Int = ..., /*1*/ y: kotlin.Int = ..., /*2*/ z: kotlin.Int = ...): kotlin.Unit
|
||||
Vendored
+22
@@ -0,0 +1,22 @@
|
||||
// DONT_RUN_GENERATED_CODE: JS
|
||||
|
||||
var counter = 0
|
||||
fun inc() = counter++
|
||||
|
||||
tailrec fun test(x: Int = 0, y: Int = inc(), z: Int = inc()) {
|
||||
if (x * 2 != y + 1 || z - y != -1)
|
||||
throw IllegalArgumentException("x=$x y=$y z=$z")
|
||||
|
||||
if (x < 100000)
|
||||
test(z = inc(), x = (counter - 1)/2 + 1)
|
||||
}
|
||||
|
||||
fun box() : String {
|
||||
counter = 4
|
||||
test(1, 1, 0)
|
||||
|
||||
counter = 0
|
||||
test(-1, -3, -4)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
package
|
||||
|
||||
public var counter: kotlin.Int
|
||||
public fun box(): kotlin.String
|
||||
public fun inc(): kotlin.Int
|
||||
public tailrec fun test(/*0*/ x: kotlin.Int = ..., /*1*/ y: kotlin.Int = ..., /*2*/ z: kotlin.Int = ...): kotlin.Unit
|
||||
@@ -23686,11 +23686,26 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
||||
runTest("compiler/testData/codegen/box/diagnostics/functions/tailRecursion/defaultArgs.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("defaultArgs2.kt")
|
||||
public void testDefaultArgs2() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/diagnostics/functions/tailRecursion/defaultArgs2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("defaultArgsOverridden.kt")
|
||||
public void testDefaultArgsOverridden() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/diagnostics/functions/tailRecursion/defaultArgsOverridden.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("defaultArgsWithSideEffects.kt")
|
||||
public void testDefaultArgsWithSideEffects() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/diagnostics/functions/tailRecursion/defaultArgsWithSideEffects.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("defaultArgsWithSideEffects2.kt")
|
||||
public void testDefaultArgsWithSideEffects2() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/diagnostics/functions/tailRecursion/defaultArgsWithSideEffects2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("extensionTailCall.kt")
|
||||
public void testExtensionTailCall() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/diagnostics/functions/tailRecursion/extensionTailCall.kt");
|
||||
|
||||
Generated
+15
@@ -23606,11 +23606,26 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
|
||||
runTest("compiler/testData/codegen/box/diagnostics/functions/tailRecursion/defaultArgs.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("defaultArgs2.kt")
|
||||
public void testDefaultArgs2() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/diagnostics/functions/tailRecursion/defaultArgs2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("defaultArgsOverridden.kt")
|
||||
public void testDefaultArgsOverridden() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/diagnostics/functions/tailRecursion/defaultArgsOverridden.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("defaultArgsWithSideEffects.kt")
|
||||
public void testDefaultArgsWithSideEffects() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/diagnostics/functions/tailRecursion/defaultArgsWithSideEffects.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("defaultArgsWithSideEffects2.kt")
|
||||
public void testDefaultArgsWithSideEffects2() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/diagnostics/functions/tailRecursion/defaultArgsWithSideEffects2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("extensionTailCall.kt")
|
||||
public void testExtensionTailCall() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/diagnostics/functions/tailRecursion/extensionTailCall.kt");
|
||||
|
||||
+15
@@ -9851,11 +9851,26 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/diagnostics/functions/tailRecursion/defaultArgs.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("defaultArgs2.kt")
|
||||
public void testDefaultArgs2() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/diagnostics/functions/tailRecursion/defaultArgs2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("defaultArgsOverridden.kt")
|
||||
public void testDefaultArgsOverridden() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/diagnostics/functions/tailRecursion/defaultArgsOverridden.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("defaultArgsWithSideEffects.kt")
|
||||
public void testDefaultArgsWithSideEffects() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/diagnostics/functions/tailRecursion/defaultArgsWithSideEffects.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("defaultArgsWithSideEffects2.kt")
|
||||
public void testDefaultArgsWithSideEffects2() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/diagnostics/functions/tailRecursion/defaultArgsWithSideEffects2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("extensionTailCall.kt")
|
||||
public void testExtensionTailCall() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/diagnostics/functions/tailRecursion/extensionTailCall.kt");
|
||||
|
||||
+15
@@ -9838,6 +9838,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class TailRecursion extends AbstractLightAnalysisModeTest {
|
||||
@TestMetadata("defaultArgsWithSideEffects.kt")
|
||||
public void ignoreDefaultArgsWithSideEffects() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/diagnostics/functions/tailRecursion/defaultArgsWithSideEffects.kt");
|
||||
}
|
||||
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath);
|
||||
}
|
||||
@@ -9851,11 +9856,21 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/diagnostics/functions/tailRecursion/defaultArgs.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("defaultArgs2.kt")
|
||||
public void testDefaultArgs2() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/diagnostics/functions/tailRecursion/defaultArgs2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("defaultArgsOverridden.kt")
|
||||
public void testDefaultArgsOverridden() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/diagnostics/functions/tailRecursion/defaultArgsOverridden.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("defaultArgsWithSideEffects2.kt")
|
||||
public void testDefaultArgsWithSideEffects2() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/diagnostics/functions/tailRecursion/defaultArgsWithSideEffects2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("extensionTailCall.kt")
|
||||
public void testExtensionTailCall() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/diagnostics/functions/tailRecursion/extensionTailCall.kt");
|
||||
|
||||
+15
@@ -9851,11 +9851,26 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/diagnostics/functions/tailRecursion/defaultArgs.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("defaultArgs2.kt")
|
||||
public void testDefaultArgs2() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/diagnostics/functions/tailRecursion/defaultArgs2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("defaultArgsOverridden.kt")
|
||||
public void testDefaultArgsOverridden() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/diagnostics/functions/tailRecursion/defaultArgsOverridden.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("defaultArgsWithSideEffects.kt")
|
||||
public void testDefaultArgsWithSideEffects() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/diagnostics/functions/tailRecursion/defaultArgsWithSideEffects.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("defaultArgsWithSideEffects2.kt")
|
||||
public void testDefaultArgsWithSideEffects2() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/diagnostics/functions/tailRecursion/defaultArgsWithSideEffects2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("extensionTailCall.kt")
|
||||
public void testExtensionTailCall() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/diagnostics/functions/tailRecursion/extensionTailCall.kt");
|
||||
|
||||
Generated
+15
@@ -7581,11 +7581,26 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/diagnostics/functions/tailRecursion/defaultArgs.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("defaultArgs2.kt")
|
||||
public void testDefaultArgs2() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/diagnostics/functions/tailRecursion/defaultArgs2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("defaultArgsOverridden.kt")
|
||||
public void testDefaultArgsOverridden() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/diagnostics/functions/tailRecursion/defaultArgsOverridden.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("defaultArgsWithSideEffects.kt")
|
||||
public void testDefaultArgsWithSideEffects() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/diagnostics/functions/tailRecursion/defaultArgsWithSideEffects.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("defaultArgsWithSideEffects2.kt")
|
||||
public void testDefaultArgsWithSideEffects2() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/diagnostics/functions/tailRecursion/defaultArgsWithSideEffects2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("extensionTailCall.kt")
|
||||
public void testExtensionTailCall() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/diagnostics/functions/tailRecursion/extensionTailCall.kt");
|
||||
|
||||
+15
@@ -8666,11 +8666,26 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/diagnostics/functions/tailRecursion/defaultArgs.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("defaultArgs2.kt")
|
||||
public void testDefaultArgs2() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/diagnostics/functions/tailRecursion/defaultArgs2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("defaultArgsOverridden.kt")
|
||||
public void testDefaultArgsOverridden() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/diagnostics/functions/tailRecursion/defaultArgsOverridden.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("defaultArgsWithSideEffects.kt")
|
||||
public void testDefaultArgsWithSideEffects() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/diagnostics/functions/tailRecursion/defaultArgsWithSideEffects.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("defaultArgsWithSideEffects2.kt")
|
||||
public void testDefaultArgsWithSideEffects2() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/diagnostics/functions/tailRecursion/defaultArgsWithSideEffects2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("extensionTailCall.kt")
|
||||
public void testExtensionTailCall() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/diagnostics/functions/tailRecursion/extensionTailCall.kt");
|
||||
|
||||
Reference in New Issue
Block a user