diff --git a/idea/jvm-debugger/jvm-debugger-evaluation/src/org/jetbrains/kotlin/idea/debugger/evaluate/compilation/CodeFragmentParameterAnalyzer.kt b/idea/jvm-debugger/jvm-debugger-evaluation/src/org/jetbrains/kotlin/idea/debugger/evaluate/compilation/CodeFragmentParameterAnalyzer.kt index befe25c2dbd..abfe96367b6 100644 --- a/idea/jvm-debugger/jvm-debugger-evaluation/src/org/jetbrains/kotlin/idea/debugger/evaluate/compilation/CodeFragmentParameterAnalyzer.kt +++ b/idea/jvm-debugger/jvm-debugger-evaluation/src/org/jetbrains/kotlin/idea/debugger/evaluate/compilation/CodeFragmentParameterAnalyzer.kt @@ -184,6 +184,18 @@ class CodeFragmentParameterAnalyzer( return null } + + override fun visitCallExpression(expression: KtCallExpression, data: Unit?): Void? { + val resolvedCall = expression.getResolvedCall(bindingContext) + if (resolvedCall != null) { + val descriptor = resolvedCall.resultingDescriptor + if (descriptor is FunctionDescriptor && descriptor.isSuspend) { + throw EvaluateExceptionUtil.createEvaluateException("Evaluation of 'suspend' calls is not supported") + } + } + + return super.visitCallExpression(expression, data) + } }, Unit) return CodeFragmentParameterInfo(parameters.values.toList(), crossingBounds) diff --git a/idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/suspendCalls.kt b/idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/suspendCalls.kt new file mode 100644 index 00000000000..489507c7d42 --- /dev/null +++ b/idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/suspendCalls.kt @@ -0,0 +1,11 @@ +package suspendCalls + +suspend fun main() { + //Breakpoint! + foo() +} + +suspend fun foo(): Int = 42 + +// EXPRESSION: foo() +// RESULT: Evaluation of 'suspend' calls is not supported \ No newline at end of file diff --git a/idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/suspendCalls.out b/idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/suspendCalls.out new file mode 100644 index 00000000000..0a4d8c8ac1d --- /dev/null +++ b/idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/suspendCalls.out @@ -0,0 +1,7 @@ +LineBreakpoint created at suspendCalls.kt:5 +Run Java +Connected to the target VM +suspendCalls.kt:5 +Disconnected from the target VM + +Process finished with exit code 0 diff --git a/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinEvaluateExpressionTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinEvaluateExpressionTestGenerated.java index d7848696b6a..0505316e4a0 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinEvaluateExpressionTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinEvaluateExpressionTestGenerated.java @@ -421,6 +421,11 @@ public class KotlinEvaluateExpressionTestGenerated extends AbstractKotlinEvaluat runTest("idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/superCallsSimple.kt"); } + @TestMetadata("suspendCalls.kt") + public void testSuspendCalls() throws Exception { + runTest("idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/suspendCalls.kt"); + } + @TestMetadata("synchronizedBlock.kt") public void testSynchronizedBlock() throws Exception { runTest("idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/synchronizedBlock.kt");