JVM_IR KT-45377 rewrite constants again after AddContinuationLowering
This commit is contained in:
committed by
TeamCityServer
parent
0f2aca3280
commit
4f250ed498
+6
@@ -9066,6 +9066,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
||||
runTest("compiler/testData/codegen/box/coroutines/kt44221.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt45377.kt")
|
||||
public void testKt45377() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/kt45377.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("lastExpressionIsLoop.kt")
|
||||
public void testLastExpressionIsLoop() throws Exception {
|
||||
|
||||
@@ -336,7 +336,7 @@ private val jvmFilePhases = listOf(
|
||||
functionReferencePhase,
|
||||
suspendLambdaPhase,
|
||||
propertyReferencePhase,
|
||||
constPhase,
|
||||
constPhase1,
|
||||
// TODO: merge the next three phases together, as visitors behave incorrectly between them
|
||||
// (backing fields moved out of companion objects are reachable by two paths):
|
||||
moveOrCopyCompanionObjectFieldsPhase,
|
||||
@@ -386,6 +386,7 @@ private val jvmFilePhases = listOf(
|
||||
|
||||
tailCallOptimizationPhase,
|
||||
addContinuationPhase,
|
||||
constPhase2, // handle const properties in default arguments of "original" suspend funs
|
||||
|
||||
innerClassesPhase,
|
||||
innerClassesMemberBodyPhase,
|
||||
|
||||
@@ -20,9 +20,15 @@ import org.jetbrains.kotlin.ir.types.isPrimitiveType
|
||||
import org.jetbrains.kotlin.ir.types.isStringClassType
|
||||
import org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid
|
||||
|
||||
internal val constPhase = makeIrFilePhase(
|
||||
internal val constPhase1 = makeIrFilePhase(
|
||||
::ConstLowering,
|
||||
name = "Const",
|
||||
name = "Const1",
|
||||
description = "Substitute calls to const properties with constant values"
|
||||
)
|
||||
|
||||
internal val constPhase2 = makeIrFilePhase(
|
||||
::ConstLowering,
|
||||
name = "Const2",
|
||||
description = "Substitute calls to const properties with constant values"
|
||||
)
|
||||
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
// WITH_RUNTIME
|
||||
// FILE: kt45377.kt
|
||||
|
||||
import kotlin.coroutines.*
|
||||
|
||||
fun runs(f: suspend () -> String): String {
|
||||
var result = ""
|
||||
f.startCoroutine(Continuation(EmptyCoroutineContext) { result = it.getOrThrow() })
|
||||
return result
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val b = B("O")
|
||||
|
||||
val s1 = runs { b.foo() }
|
||||
if (s1 != "OK") return "Failed: s1=$s1"
|
||||
|
||||
var s2 = runs { b.foo("K") }
|
||||
if (s2 != "OK") return "Failed: s2=$s2"
|
||||
|
||||
val a: A = b
|
||||
|
||||
val s3 = runs { a.foo() }
|
||||
if (s3 != "OK") return "Failed: s3=$s3"
|
||||
|
||||
val s4 = runs { a.foo("K")}
|
||||
if (s4 != "OK") return "Failed: s4=$s4"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
// FILE: file1.kt
|
||||
private const val K = "K"
|
||||
|
||||
interface A {
|
||||
suspend fun foo(k: String = K): String
|
||||
}
|
||||
|
||||
// FILE: file2.kt
|
||||
class B(val o: String) : A {
|
||||
override suspend fun foo(k: String) = o + k
|
||||
}
|
||||
+6
@@ -9066,6 +9066,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/coroutines/kt44221.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt45377.kt")
|
||||
public void testKt45377() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/kt45377.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("lastExpressionIsLoop.kt")
|
||||
public void testLastExpressionIsLoop() throws Exception {
|
||||
|
||||
+6
@@ -9066,6 +9066,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/coroutines/kt44221.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt45377.kt")
|
||||
public void testKt45377() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/kt45377.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("lastExpressionIsLoop.kt")
|
||||
public void testLastExpressionIsLoop() throws Exception {
|
||||
|
||||
+5
@@ -7079,6 +7079,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/coroutines/kt44221.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt45377.kt")
|
||||
public void testKt45377() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/kt45377.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("lastExpressionIsLoop.kt")
|
||||
public void testLastExpressionIsLoop() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/lastExpressionIsLoop.kt");
|
||||
|
||||
js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java
Generated
+5
@@ -6328,6 +6328,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes
|
||||
runTest("compiler/testData/codegen/box/coroutines/kt44221.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt45377.kt")
|
||||
public void testKt45377() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/kt45377.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("lastExpressionIsLoop.kt")
|
||||
public void testLastExpressionIsLoop() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/lastExpressionIsLoop.kt");
|
||||
|
||||
Generated
+5
@@ -5749,6 +5749,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/coroutines/kt44221.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt45377.kt")
|
||||
public void testKt45377() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/kt45377.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("lastExpressionIsLoop.kt")
|
||||
public void testLastExpressionIsLoop() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/lastExpressionIsLoop.kt");
|
||||
|
||||
Generated
+5
@@ -5749,6 +5749,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/coroutines/kt44221.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt45377.kt")
|
||||
public void testKt45377() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/kt45377.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("lastExpressionIsLoop.kt")
|
||||
public void testLastExpressionIsLoop() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/lastExpressionIsLoop.kt");
|
||||
|
||||
Reference in New Issue
Block a user