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 e040b4a232f..0479d14c918 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/FrameVisitor.kt +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/FrameVisitor.kt @@ -38,6 +38,10 @@ class FrameVisitor(context: EvaluationContextImpl) { private val project = context.debugProcess.project private val frame = context.frameProxy?.stackFrame + companion object { + val OBJECT_TYPE = Type.getType(Any::class.java) + } + public fun findValue(name: String, asmType: Type?, checkType: Boolean, failIfNotFound: Boolean): Value? { if (frame == null) return null @@ -169,6 +173,8 @@ class FrameVisitor(context: EvaluationContextImpl) { if (!shouldCheckType || asmType == null || value.asmType == asmType) return true if (project == null) return false + if (asmType == OBJECT_TYPE) return true + if ((value.obj() as? com.sun.jdi.ObjectReference)?.referenceType().isSubclass(asmType.className)) { return true } 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 f933d22c897..0a2cc14a4ab 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinEvaluationBuilder.kt +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinEvaluationBuilder.kt @@ -270,7 +270,7 @@ class KotlinEvaluator(val codeFragment: KtCodeFragment, val sourcePosition: Sour } if (!AsmUtil.isPrimitive(parameterType) && AsmUtil.isPrimitive(argumentType)) { - if (parameterType == AsmUtil.boxType(argumentType)) { + if (parameterType == FrameVisitor.OBJECT_TYPE || parameterType == AsmUtil.boxType(argumentType)) { return eval.boxType(argumentValue) } } diff --git a/idea/testData/debugger/tinyApp/outs/boxReturnValue.out b/idea/testData/debugger/tinyApp/outs/boxReturnValue.out new file mode 100644 index 00000000000..a004873fc48 --- /dev/null +++ b/idea/testData/debugger/tinyApp/outs/boxReturnValue.out @@ -0,0 +1,8 @@ +LineBreakpoint created at boxReturnValue.kt:7 +!JDK_HOME!\bin\java -agentlib:jdwp=transport=dt_socket,address=!HOST_NAME!:!HOST_PORT!,suspend=y,server=n -Dfile.encoding=!FILE_ENCODING! -classpath !OUTPUT_PATH!;!KOTLIN_RUNTIME!;!CUSTOM_LIBRARY!;!RT_JAR! boxReturnValue.BoxReturnValueKt +Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket' +boxReturnValue.kt:7 +Compile bytecode for x +Disconnected from the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket' + +Process finished with exit code 0 diff --git a/idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/boxReturnValue.kt b/idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/boxReturnValue.kt new file mode 100644 index 00000000000..dac90da2de3 --- /dev/null +++ b/idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/boxReturnValue.kt @@ -0,0 +1,12 @@ +package boxReturnValue + +inline fun useInline(x: X) { + // EXPRESSION: x + // RESULT: instance of java.lang.Integer(id=ID): Ljava/lang/Integer; + //Breakpoint! + val a = 1 +} + +fun main(args: Array) { + useInline(1) +} \ No newline at end of file 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 861496582f0..81a59eb6e1c 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinEvaluateExpressionTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinEvaluateExpressionTestGenerated.java @@ -61,6 +61,12 @@ public class KotlinEvaluateExpressionTestGenerated extends AbstractKotlinEvaluat doSingleBreakpointTest(fileName); } + @TestMetadata("boxReturnValue.kt") + public void testBoxReturnValue() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/boxReturnValue.kt"); + doSingleBreakpointTest(fileName); + } + @TestMetadata("breakpointInInlineFun.kt") public void testBreakpointInInlineFun() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/breakpointInInlineFun.kt");