diff --git a/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java index 2a1f9d5ef54..9ef78867e87 100644 --- a/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java @@ -6523,11 +6523,21 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/coroutines/builderInferenceAndGenericArrayAcessCall.kt"); } + @TestMetadata("captureInfixFun.kt") + public void testCaptureInfixFun() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/captureInfixFun.kt"); + } + @TestMetadata("captureMutableLocalVariableInsideCoroutineBlock.kt") public void testCaptureMutableLocalVariableInsideCoroutineBlock() throws Exception { runTest("compiler/testData/codegen/box/coroutines/captureMutableLocalVariableInsideCoroutineBlock.kt"); } + @TestMetadata("captureUnaryOperator.kt") + public void testCaptureUnaryOperator() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/captureUnaryOperator.kt"); + } + @TestMetadata("capturedVarInSuspendLambda.kt") public void testCapturedVarInSuspendLambda_1_3() throws Exception { runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/capturedVarInSuspendLambda.kt", "kotlin.coroutines"); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/ControlFlowInformationProvider.kt b/compiler/frontend/src/org/jetbrains/kotlin/cfg/ControlFlowInformationProvider.kt index 89d1f36b1d7..bc28565c318 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/cfg/ControlFlowInformationProvider.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/cfg/ControlFlowInformationProvider.kt @@ -887,7 +887,9 @@ class ControlFlowInformationProvider private constructor( } instruction.next?.let { dfs(it) } - } else if (instruction.element is KtNameReferenceExpression) { + } else if (instruction.element is KtNameReferenceExpression || instruction.element is KtBinaryExpression || + instruction.element is KtUnaryExpression + ) { val call = instruction.element.getResolvedCall(trace.bindingContext) if (call is VariableAsFunctionResolvedCall) { (call.variableCall.dispatchReceiver as? ExtensionReceiver)?.declarationDescriptor?.apply { markIfNeeded() } diff --git a/compiler/testData/codegen/box/coroutines/captureInfixFun.kt b/compiler/testData/codegen/box/coroutines/captureInfixFun.kt new file mode 100644 index 00000000000..a80113366b8 --- /dev/null +++ b/compiler/testData/codegen/box/coroutines/captureInfixFun.kt @@ -0,0 +1,35 @@ +// WITH_RUNTIME +// WITH_COROUTINES + +import helpers.* +import kotlin.coroutines.* + +fun builder(c: suspend Context.() -> Unit) { + c.startCoroutine(Context(), EmptyContinuation) +} + +class Foo { + fun foo() { + val fionaClient = Any() + coVerify { fionaClient was Called } + } +} + +object Called + +var res = "FAIL" + +class Context { + infix fun Any.was(called: Called) { + res = "OK" + } +} + +fun coVerify(verifyBlock: suspend Context.() -> Unit) { + builder(verifyBlock) +} + +fun box(): String { + Foo().foo() + return res +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/coroutines/captureUnaryOperator.kt b/compiler/testData/codegen/box/coroutines/captureUnaryOperator.kt new file mode 100644 index 00000000000..ad7bb9c6e92 --- /dev/null +++ b/compiler/testData/codegen/box/coroutines/captureUnaryOperator.kt @@ -0,0 +1,33 @@ +// WITH_RUNTIME +// WITH_COROUTINES + +import helpers.* +import kotlin.coroutines.* + +fun builder(c: suspend Context.() -> Unit) { + c.startCoroutine(Context(), EmptyContinuation) +} + +class Foo { + fun foo() { + val fionaClient = Any() + coVerify { !fionaClient } + } +} + +var res = "FAIL" + +class Context { + operator fun Any.not() { + res = "OK" + } +} + +fun coVerify(verifyBlock: suspend Context.() -> Unit) { + builder(verifyBlock) +} + +fun box(): String { + Foo().foo() + return res +} \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java index eda85ca9843..b7ee8857843 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java @@ -6593,11 +6593,21 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/coroutines/builderInferenceAndGenericArrayAcessCall.kt"); } + @TestMetadata("captureInfixFun.kt") + public void testCaptureInfixFun() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/captureInfixFun.kt"); + } + @TestMetadata("captureMutableLocalVariableInsideCoroutineBlock.kt") public void testCaptureMutableLocalVariableInsideCoroutineBlock() throws Exception { runTest("compiler/testData/codegen/box/coroutines/captureMutableLocalVariableInsideCoroutineBlock.kt"); } + @TestMetadata("captureUnaryOperator.kt") + public void testCaptureUnaryOperator() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/captureUnaryOperator.kt"); + } + @TestMetadata("capturedVarInSuspendLambda.kt") public void testCapturedVarInSuspendLambda_1_2() throws Exception { runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/capturedVarInSuspendLambda.kt", "kotlin.coroutines.experimental"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 631e22f8bd2..1fcc1f299a4 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -6593,11 +6593,21 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/coroutines/builderInferenceAndGenericArrayAcessCall.kt"); } + @TestMetadata("captureInfixFun.kt") + public void testCaptureInfixFun() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/captureInfixFun.kt"); + } + @TestMetadata("captureMutableLocalVariableInsideCoroutineBlock.kt") public void testCaptureMutableLocalVariableInsideCoroutineBlock() throws Exception { runTest("compiler/testData/codegen/box/coroutines/captureMutableLocalVariableInsideCoroutineBlock.kt"); } + @TestMetadata("captureUnaryOperator.kt") + public void testCaptureUnaryOperator() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/captureUnaryOperator.kt"); + } + @TestMetadata("capturedVarInSuspendLambda.kt") public void testCapturedVarInSuspendLambda_1_2() throws Exception { runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/capturedVarInSuspendLambda.kt", "kotlin.coroutines.experimental"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java index 2835a91a286..3d2e468f177 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java @@ -6523,11 +6523,21 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/coroutines/builderInferenceAndGenericArrayAcessCall.kt"); } + @TestMetadata("captureInfixFun.kt") + public void testCaptureInfixFun() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/captureInfixFun.kt"); + } + @TestMetadata("captureMutableLocalVariableInsideCoroutineBlock.kt") public void testCaptureMutableLocalVariableInsideCoroutineBlock() throws Exception { runTest("compiler/testData/codegen/box/coroutines/captureMutableLocalVariableInsideCoroutineBlock.kt"); } + @TestMetadata("captureUnaryOperator.kt") + public void testCaptureUnaryOperator() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/captureUnaryOperator.kt"); + } + @TestMetadata("capturedVarInSuspendLambda.kt") public void testCapturedVarInSuspendLambda_1_3() throws Exception { runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/capturedVarInSuspendLambda.kt", "kotlin.coroutines"); diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java index 764bfee8b2b..2f053d982cd 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java @@ -5403,11 +5403,21 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes runTest("compiler/testData/codegen/box/coroutines/builderInferenceAndGenericArrayAcessCall.kt"); } + @TestMetadata("captureInfixFun.kt") + public void testCaptureInfixFun() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/captureInfixFun.kt"); + } + @TestMetadata("captureMutableLocalVariableInsideCoroutineBlock.kt") public void testCaptureMutableLocalVariableInsideCoroutineBlock() throws Exception { runTest("compiler/testData/codegen/box/coroutines/captureMutableLocalVariableInsideCoroutineBlock.kt"); } + @TestMetadata("captureUnaryOperator.kt") + public void testCaptureUnaryOperator() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/captureUnaryOperator.kt"); + } + @TestMetadata("capturedVarInSuspendLambda.kt") public void testCapturedVarInSuspendLambda_1_3() throws Exception { runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/capturedVarInSuspendLambda.kt", "kotlin.coroutines"); diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java index b92e53a71a7..a9a1376faf1 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java @@ -5403,11 +5403,21 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/coroutines/builderInferenceAndGenericArrayAcessCall.kt"); } + @TestMetadata("captureInfixFun.kt") + public void testCaptureInfixFun() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/captureInfixFun.kt"); + } + @TestMetadata("captureMutableLocalVariableInsideCoroutineBlock.kt") public void testCaptureMutableLocalVariableInsideCoroutineBlock() throws Exception { runTest("compiler/testData/codegen/box/coroutines/captureMutableLocalVariableInsideCoroutineBlock.kt"); } + @TestMetadata("captureUnaryOperator.kt") + public void testCaptureUnaryOperator() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/captureUnaryOperator.kt"); + } + @TestMetadata("capturedVarInSuspendLambda.kt") public void testCapturedVarInSuspendLambda_1_3() throws Exception { runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/capturedVarInSuspendLambda.kt", "kotlin.coroutines"); diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java index 4aa5e187495..6059bac5be6 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java @@ -5403,11 +5403,21 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/coroutines/builderInferenceAndGenericArrayAcessCall.kt"); } + @TestMetadata("captureInfixFun.kt") + public void testCaptureInfixFun() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/captureInfixFun.kt"); + } + @TestMetadata("captureMutableLocalVariableInsideCoroutineBlock.kt") public void testCaptureMutableLocalVariableInsideCoroutineBlock() throws Exception { runTest("compiler/testData/codegen/box/coroutines/captureMutableLocalVariableInsideCoroutineBlock.kt"); } + @TestMetadata("captureUnaryOperator.kt") + public void testCaptureUnaryOperator() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/captureUnaryOperator.kt"); + } + @TestMetadata("capturedVarInSuspendLambda.kt") public void testCapturedVarInSuspendLambda_1_3() throws Exception { runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/capturedVarInSuspendLambda.kt", "kotlin.coroutines");