diff --git a/idea/jvm-debugger/jvm-debugger-evaluation/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinEvaluatorBuilder.kt b/idea/jvm-debugger/jvm-debugger-evaluation/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinEvaluatorBuilder.kt index 115b62350e4..94a707469fa 100644 --- a/idea/jvm-debugger/jvm-debugger-evaluation/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinEvaluatorBuilder.kt +++ b/idea/jvm-debugger/jvm-debugger-evaluation/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinEvaluatorBuilder.kt @@ -333,7 +333,9 @@ class KotlinEvaluator(val codeFragment: KtCodeFragment, val sourcePosition: Sour return method.name().endsWith("\$default") && DEFAULT_METHOD_MARKERS.any { desc.contains("I${it.descriptor})") } } - if (parameter in compiledData.crossingBounds) { + if (parameter.kind == CodeFragmentParameter.Kind.COROUTINE_CONTEXT) { + evaluationException("'coroutineContext' is not available") + } else if (parameter in compiledData.crossingBounds) { evaluationException("'$name' is not captured") } else if (parameter.kind == CodeFragmentParameter.Kind.FIELD_VAR) { evaluationException("Cannot find the backing field '${parameter.name}'") diff --git a/idea/jvm-debugger/jvm-debugger-evaluation/src/org/jetbrains/kotlin/idea/debugger/evaluate/variables/VariableFinder.kt b/idea/jvm-debugger/jvm-debugger-evaluation/src/org/jetbrains/kotlin/idea/debugger/evaluate/variables/VariableFinder.kt index 27b35f336f0..08145228264 100644 --- a/idea/jvm-debugger/jvm-debugger-evaluation/src/org/jetbrains/kotlin/idea/debugger/evaluate/variables/VariableFinder.kt +++ b/idea/jvm-debugger/jvm-debugger-evaluation/src/org/jetbrains/kotlin/idea/debugger/evaluate/variables/VariableFinder.kt @@ -14,6 +14,7 @@ import org.jetbrains.kotlin.codegen.AsmUtil import org.jetbrains.kotlin.codegen.AsmUtil.getCapturedFieldName import org.jetbrains.kotlin.codegen.AsmUtil.getLabeledThisName import org.jetbrains.kotlin.codegen.coroutines.CONTINUATION_VARIABLE_NAME +import org.jetbrains.kotlin.codegen.coroutines.SUSPEND_FUNCTION_CONTINUATION_PARAMETER import org.jetbrains.kotlin.codegen.inline.INLINE_FUN_VAR_SUFFIX import org.jetbrains.kotlin.codegen.inline.INLINE_TRANSFORMATION_SUFFIX import org.jetbrains.kotlin.idea.core.util.mergeAttachments @@ -370,7 +371,10 @@ class VariableFinder(val context: ExecutionContext) { return null } - val continuationVariable = frameProxy.safeVisibleVariableByName(CONTINUATION_VARIABLE_NAME) ?: return null + val continuationVariable = frameProxy.safeVisibleVariableByName(CONTINUATION_VARIABLE_NAME) + ?: frameProxy.safeVisibleVariableByName(SUSPEND_FUNCTION_CONTINUATION_PARAMETER) + ?: return null + val continuation = frameProxy.getValue(continuationVariable) as? ObjectReference ?: return null return findCoroutineContextForContinuation(continuation) } diff --git a/idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/frame/coroutineContextWithoutSuspend.kt b/idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/frame/coroutineContextWithoutSuspend.kt new file mode 100644 index 00000000000..179e40208c7 --- /dev/null +++ b/idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/frame/coroutineContextWithoutSuspend.kt @@ -0,0 +1,15 @@ +package coroutineContextWithoutSuspend + +import kotlin.coroutines.coroutineContext + +suspend fun main() { + foo() +} + +private suspend fun foo() { + //Breakpoint! + val a = 5 +} + +// EXPRESSION: coroutineContext +// RESULT: instance of kotlin.coroutines.EmptyCoroutineContext(id=ID): Lkotlin/coroutines/EmptyCoroutineContext; \ No newline at end of file diff --git a/idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/frame/coroutineContextWithoutSuspend.out b/idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/frame/coroutineContextWithoutSuspend.out new file mode 100644 index 00000000000..feb66ec3860 --- /dev/null +++ b/idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/frame/coroutineContextWithoutSuspend.out @@ -0,0 +1,8 @@ +LineBreakpoint created at coroutineContextWithoutSuspend.kt:11 +Run Java +Connected to the target VM +coroutineContextWithoutSuspend.kt:11 +Compile bytecode for coroutineContext +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 c0645664bd7..93c9bfa7718 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinEvaluateExpressionTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinEvaluateExpressionTestGenerated.java @@ -700,6 +700,11 @@ public class KotlinEvaluateExpressionTestGenerated extends AbstractKotlinEvaluat runTest("idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/frame/coroutineContextLambda.kt"); } + @TestMetadata("coroutineContextWithoutSuspend.kt") + public void testCoroutineContextWithoutSuspend() throws Exception { + runTest("idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/frame/coroutineContextWithoutSuspend.kt"); + } + @TestMetadata("defaultImplsMangling.kt") public void testDefaultImplsMangling() throws Exception { runTest("idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/frame/defaultImplsMangling.kt");