diff --git a/idea/jvm-debugger/eval4j/src/org/jetbrains/eval4j/jdi/jdiEval.kt b/idea/jvm-debugger/eval4j/src/org/jetbrains/eval4j/jdi/jdiEval.kt index ba42329d82f..afdf256f518 100644 --- a/idea/jvm-debugger/eval4j/src/org/jetbrains/eval4j/jdi/jdiEval.kt +++ b/idea/jvm-debugger/eval4j/src/org/jetbrains/eval4j/jdi/jdiEval.kt @@ -444,7 +444,7 @@ class JDIEval( "(L${OBJECT.internalName};[L${OBJECT.internalName};)L${OBJECT.internalName};", true ), - listOf(instance, *args.map { it.asValue() }.toTypedArray()) + listOf(instance, mirrorOfArgs(args)) ) if (methodDesc.returnType.sort != Type.OBJECT && methodDesc.returnType.sort != Type.ARRAY && methodDesc.returnType.sort != Type.VOID) { @@ -453,6 +453,17 @@ class JDIEval( return invocationResult } + private fun mirrorOfArgs(args: List): Value { + val arrayObject = newArray(Type.getType("[" + OBJECT.descriptor), args.size) + + args.forEachIndexed { index, value -> + val indexValue = vm.mirrorOf(index).asValue() + setArrayElement(arrayObject, indexValue, value.asValue()) + } + + return arrayObject + } + private fun List.disableCollection() { forEach { (it as? ObjectReference)?.disableCollection() } } diff --git a/idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/typedArray.kt b/idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/typedArray.kt new file mode 100644 index 00000000000..5ae691a4aba --- /dev/null +++ b/idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/typedArray.kt @@ -0,0 +1,17 @@ +package typedArray + +fun main() { + val list = listOf("foo") + //Breakpoint! + val a = 5 +} + +fun block(block: () -> T): T { + return block() +} + +// EXPRESSION: list.toTypedArray().size +// RESULT: 1: I + +// EXPRESSION: block { list.toTypedArray().size } +// RESULT: 1: I \ No newline at end of file diff --git a/idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/typedArray.out b/idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/typedArray.out new file mode 100644 index 00000000000..40f22f87872 --- /dev/null +++ b/idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/typedArray.out @@ -0,0 +1,9 @@ +LineBreakpoint created at typedArray.kt:6 +Run Java +Connected to the target VM +typedArray.kt:6 +Compile bytecode for list.toTypedArray().size +Compile bytecode for block { list.toTypedArray().size } +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 2234b6a41c8..358cf65dabb 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/typeParameterRef.kt"); } + @TestMetadata("typedArray.kt") + public void testTypedArray() throws Exception { + runTest("idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/typedArray.kt"); + } + @TestMetadata("unboxParam.kt") public void testUnboxParam() throws Exception { runTest("idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/unboxParam.kt");