Debugger: Fix toTypedArray() evaluation (KT-8579)
This commit is contained in:
@@ -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<jdi_Value?>): 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<jdi_Value?>.disableCollection() {
|
||||
forEach { (it as? ObjectReference)?.disableCollection() }
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package typedArray
|
||||
|
||||
fun main() {
|
||||
val list = listOf<CharSequence>("foo")
|
||||
//Breakpoint!
|
||||
val a = 5
|
||||
}
|
||||
|
||||
fun <T> block(block: () -> T): T {
|
||||
return block()
|
||||
}
|
||||
|
||||
// EXPRESSION: list.toTypedArray().size
|
||||
// RESULT: 1: I
|
||||
|
||||
// EXPRESSION: block { list.toTypedArray().size }
|
||||
// RESULT: 1: I
|
||||
@@ -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
|
||||
Generated
+5
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user