diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinEvaluateExpressionCache.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinEvaluateExpressionCache.kt index ef104b5cdd4..8d3aef846e0 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinEvaluateExpressionCache.kt +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinEvaluateExpressionCache.kt @@ -30,6 +30,7 @@ import org.jetbrains.kotlin.types.JetType import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.apache.log4j.Logger +import org.jetbrains.eval4j.Value import org.jetbrains.kotlin.idea.util.application.runReadAction class KotlinEvaluateExpressionCache(val project: Project) { @@ -92,15 +93,15 @@ class KotlinEvaluateExpressionCache(val project: Project) { val parameters: ParametersDescriptor ) - class ParametersDescriptor : Iterable> { - private val list = ArrayList>() + class ParametersDescriptor : Iterable { + private val list = ArrayList() - fun add(name: String, jetType: JetType) { - list.add(name to jetType) + fun add(name: String, jetType: JetType, value: Value? = null) { + list.add(Parameter(name, jetType, value)) } - fun getParameterNames() = list.map { it.first } - override fun iterator() = list.iterator() } + + data class Parameter(val callText: String, val type: JetType, val value: Value? = null) } 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 fd4b4548289..17391dbb4cc 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinEvaluationBuilder.kt +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinEvaluationBuilder.kt @@ -217,7 +217,7 @@ class KotlinEvaluator(val codeFragment: JetCodeFragment, override fun visitMethod(access: Int, name: String, desc: String, signature: String?, exceptions: Array?): MethodVisitor? { if (name == compiledData.funName) { val argumentTypes = Type.getArgumentTypes(desc) - val args = context.getArgumentsForEval4j(compiledData.parameters.getParameterNames(), argumentTypes) + val args = context.getArgumentsForEval4j(compiledData.parameters, argumentTypes) return object : MethodNode(Opcodes.ASM5, access, name, desc, signature, exceptions) { override fun visitEnd() { @@ -307,9 +307,11 @@ class KotlinEvaluator(val codeFragment: JetCodeFragment, } } - private fun EvaluationContextImpl.getArgumentsForEval4j(parameterNames: List, parameterTypes: Array): List { + private fun EvaluationContextImpl.getArgumentsForEval4j(parameters: ParametersDescriptor, parameterTypes: Array): List { val frameVisitor = FrameVisitor(this) - return parameterNames.zip(parameterTypes).map { frameVisitor.findValue(it.first, it.second, checkType = false, failIfNotFound = true)!! } + return parameters.zip(parameterTypes).map { + frameVisitor.findValue(it.first.callText, it.second, checkType = false, failIfNotFound = true)!! + } } private fun createClassFileFactory( @@ -353,9 +355,8 @@ class KotlinEvaluator(val codeFragment: JetCodeFragment, val valueParameters = extractedFunction.getValueParameters() var paramIndex = 0 for (param in parameters) { - val (callText, type) = param - if (callText.contains(THIS_NAME)) continue + if (param.callText.contains(THIS_NAME)) continue val valueParameter = valueParameters[paramIndex++] @@ -368,7 +369,7 @@ class KotlinEvaluator(val codeFragment: JetCodeFragment, exception("An exception occurs during Evaluate Expression Action") } - state.getBindingTrace().recordAnonymousType(paramRef, callText, frameVisitor) + state.getBindingTrace().recordAnonymousType(paramRef, param.callText, frameVisitor) } KotlinCodegenFacade.compileCorrectFiles(state, CompilationErrorHandler.THROW_EXCEPTION)