FE: properly clear the deferred generator stack
Before this commit the stack wasn't cleared for read variable case. #KT-47168 Fixed
This commit is contained in:
+6
@@ -7538,6 +7538,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
|||||||
runTest("compiler/testData/codegen/box/contracts/kt45236.kt");
|
runTest("compiler/testData/codegen/box/contracts/kt45236.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt47168.kt")
|
||||||
|
public void testKt47168() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/contracts/kt47168.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("lambdaParameter.kt")
|
@TestMetadata("lambdaParameter.kt")
|
||||||
public void testLambdaParameter() throws Exception {
|
public void testLambdaParameter() throws Exception {
|
||||||
|
|||||||
@@ -1574,19 +1574,18 @@ class ControlFlowProcessor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (resolvedCall.resultingDescriptor is VariableDescriptor) {
|
val callInstruction = if (resolvedCall.resultingDescriptor is VariableDescriptor) {
|
||||||
// If a callee of the call is just a variable (without 'invoke'), 'read variable' is generated.
|
// If a callee of the call is just a variable (without 'invoke'), 'read variable' is generated.
|
||||||
// todo : process arguments for such a case (KT-5387)
|
// todo : process arguments for such a case (KT-5387)
|
||||||
val callExpression =
|
val callExpression =
|
||||||
callElement as? KtExpression ?: error("Variable-based call without callee expression: " + callElement.text)
|
callElement as? KtExpression ?: error("Variable-based call without callee expression: " + callElement.text)
|
||||||
assert(parameterValues.isEmpty()) { "Variable-based call with non-empty argument list: " + callElement.text }
|
assert(parameterValues.isEmpty()) { "Variable-based call with non-empty argument list: " + callElement.text }
|
||||||
return builder.readVariable(callExpression, resolvedCall, receivers)
|
builder.readVariable(callExpression, resolvedCall, receivers)
|
||||||
|
} else {
|
||||||
|
mark(resolvedCall.call.callElement)
|
||||||
|
builder.call(callElement, resolvedCall, receivers, parameterValues)
|
||||||
}
|
}
|
||||||
|
deferredGeneratorsStack.pop().forEach { it.invoke(builder) }
|
||||||
mark(resolvedCall.call.callElement)
|
|
||||||
val callInstruction = builder.call(callElement, resolvedCall, receivers, parameterValues)
|
|
||||||
val deferredGeneratorsForCall = deferredGeneratorsStack.pop()
|
|
||||||
deferredGeneratorsForCall.forEach { it.invoke(builder) }
|
|
||||||
return callInstruction
|
return callInstruction
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
// !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts
|
||||||
|
// IGNORE_BACKEND: NATIVE
|
||||||
|
import kotlin.contracts.*
|
||||||
|
|
||||||
|
inline fun foo(x: () -> String, y: () -> String): String {
|
||||||
|
contract {
|
||||||
|
callsInPlace(x, InvocationKind.EXACTLY_ONCE)
|
||||||
|
callsInPlace(y, InvocationKind.EXACTLY_ONCE)
|
||||||
|
}
|
||||||
|
return x() + y()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
val y = { "K" }
|
||||||
|
return foo({ "O" }, y)
|
||||||
|
}
|
||||||
+6
@@ -7538,6 +7538,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
runTest("compiler/testData/codegen/box/contracts/kt45236.kt");
|
runTest("compiler/testData/codegen/box/contracts/kt45236.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt47168.kt")
|
||||||
|
public void testKt47168() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/contracts/kt47168.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("lambdaParameter.kt")
|
@TestMetadata("lambdaParameter.kt")
|
||||||
public void testLambdaParameter() throws Exception {
|
public void testLambdaParameter() throws Exception {
|
||||||
|
|||||||
+6
@@ -7538,6 +7538,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
runTest("compiler/testData/codegen/box/contracts/kt45236.kt");
|
runTest("compiler/testData/codegen/box/contracts/kt45236.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt47168.kt")
|
||||||
|
public void testKt47168() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/contracts/kt47168.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("lambdaParameter.kt")
|
@TestMetadata("lambdaParameter.kt")
|
||||||
public void testLambdaParameter() throws Exception {
|
public void testLambdaParameter() throws Exception {
|
||||||
|
|||||||
+5
@@ -5744,6 +5744,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
|||||||
runTest("compiler/testData/codegen/box/contracts/kt45236.kt");
|
runTest("compiler/testData/codegen/box/contracts/kt45236.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt47168.kt")
|
||||||
|
public void testKt47168() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/contracts/kt47168.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("lambdaParameter.kt")
|
@TestMetadata("lambdaParameter.kt")
|
||||||
public void testLambdaParameter() throws Exception {
|
public void testLambdaParameter() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/contracts/lambdaParameter.kt");
|
runTest("compiler/testData/codegen/box/contracts/lambdaParameter.kt");
|
||||||
|
|||||||
js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java
Generated
+5
@@ -5018,6 +5018,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes
|
|||||||
runTest("compiler/testData/codegen/box/contracts/kt45236.kt");
|
runTest("compiler/testData/codegen/box/contracts/kt45236.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt47168.kt")
|
||||||
|
public void testKt47168() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/contracts/kt47168.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("lambdaParameter.kt")
|
@TestMetadata("lambdaParameter.kt")
|
||||||
public void testLambdaParameter() throws Exception {
|
public void testLambdaParameter() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/contracts/lambdaParameter.kt");
|
runTest("compiler/testData/codegen/box/contracts/lambdaParameter.kt");
|
||||||
|
|||||||
Generated
+5
@@ -4424,6 +4424,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
|||||||
runTest("compiler/testData/codegen/box/contracts/kt45236.kt");
|
runTest("compiler/testData/codegen/box/contracts/kt45236.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt47168.kt")
|
||||||
|
public void testKt47168() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/contracts/kt47168.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("lambdaParameter.kt")
|
@TestMetadata("lambdaParameter.kt")
|
||||||
public void testLambdaParameter() throws Exception {
|
public void testLambdaParameter() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/contracts/lambdaParameter.kt");
|
runTest("compiler/testData/codegen/box/contracts/lambdaParameter.kt");
|
||||||
|
|||||||
Generated
+5
@@ -4424,6 +4424,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
|||||||
runTest("compiler/testData/codegen/box/contracts/kt45236.kt");
|
runTest("compiler/testData/codegen/box/contracts/kt45236.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt47168.kt")
|
||||||
|
public void testKt47168() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/contracts/kt47168.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("lambdaParameter.kt")
|
@TestMetadata("lambdaParameter.kt")
|
||||||
public void testLambdaParameter() throws Exception {
|
public void testLambdaParameter() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/contracts/lambdaParameter.kt");
|
runTest("compiler/testData/codegen/box/contracts/lambdaParameter.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user