diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/FrameVisitor.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/FrameVisitor.kt index 607685938cc..2920a2c0559 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/FrameVisitor.kt +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/FrameVisitor.kt @@ -179,7 +179,7 @@ class FrameVisitor(context: EvaluationContextImpl) { return this.asmType.getSort() == Type.OBJECT && this.asmType.getInternalName().startsWith(AsmTypes.REF_TYPE_PREFIX) } - private fun getValueIfSharedVar(value: Value, expectedType: Type?, checkType: Boolean): Value? { + fun getValueIfSharedVar(value: Value, expectedType: Type?, checkType: Boolean): Value? { if (!value.isSharedVar()) return null val sharedVarValue = getField(value, "element", expectedType, checkType) diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinEvaluationBuilder.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinEvaluationBuilder.kt index ccb7ccc2800..263c867fb34 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinEvaluationBuilder.kt +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinEvaluationBuilder.kt @@ -139,14 +139,12 @@ class KotlinEvaluator(val codeFragment: KtCodeFragment, } val result = runEval4j(context, compiledData) - val virtualMachine = context.debugProcess.virtualMachineProxy.virtualMachine - // If bytecode was taken from cache and exception was thrown - recompile bytecode and run eval4j again if (isCompiledDataFromCache && result is ExceptionThrown && result.kind == ExceptionThrown.ExceptionKind.BROKEN_CODE) { - return runEval4j(context, extractAndCompile(codeFragment, sourcePosition, context)).toJdiValue(virtualMachine) + return runEval4j(context, extractAndCompile(codeFragment, sourcePosition, context)).toJdiValue(context) } - return result.toJdiValue(virtualMachine) + return result.toJdiValue(context) } catch(e: EvaluateException) { throw e @@ -277,7 +275,7 @@ class KotlinEvaluator(val codeFragment: KtCodeFragment, return argumentValue } - private fun InterpreterResult.toJdiValue(vm: VirtualMachine): com.sun.jdi.Value? { + private fun InterpreterResult.toJdiValue(context: EvaluationContextImpl): com.sun.jdi.Value? { val jdiValue = when (this) { is ValueReturned -> result is ExceptionThrown -> { @@ -291,7 +289,10 @@ class KotlinEvaluator(val codeFragment: KtCodeFragment, is AbnormalTermination -> exception(message) else -> throw IllegalStateException("Unknown result value produced by eval4j") } - return jdiValue.asJdiValue(vm, jdiValue.asmType) + + val vm = context.debugProcess.virtualMachineProxy.virtualMachine + val sharedVar = FrameVisitor(context).getValueIfSharedVar(jdiValue, jdiValue.asmType, false) + return sharedVar?.asJdiValue(vm, sharedVar.asmType) ?: jdiValue.asJdiValue(vm, jdiValue.asmType) } private fun ExtractionResult.getParametersForDebugger(fragment: KtCodeFragment): ParametersDescriptor {