From 6d3a7102d5edefe918751c587d11639b60dd833c Mon Sep 17 00:00:00 2001 From: Mikhail Zarechenskiy Date: Fri, 31 May 2019 15:52:31 +0300 Subject: [PATCH] Fix evaluation of local functions for new-inference Plus, additionally fix evaluation of generic local functions everywhere The problem was that in new-inference we create more substituted descriptors while old inference tries to preserve original ones. Later, backend fails to retrieve those descriptors as it uses originals. But, again, this worked only for simple functions, for generic functions debugger with new and old inference worked incorrectly #KT-31785 Fixed --- .../evaluate/compilation/CodeFragmentParameterAnalyzer.kt | 2 +- .../tinyApp/src/evaluate/multipleBreakpoints/localFun.kt | 7 +++++++ .../tinyApp/src/evaluate/multipleBreakpoints/localFun.out | 3 +++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/idea/jvm-debugger/jvm-debugger-evaluation/src/org/jetbrains/kotlin/idea/debugger/evaluate/compilation/CodeFragmentParameterAnalyzer.kt b/idea/jvm-debugger/jvm-debugger-evaluation/src/org/jetbrains/kotlin/idea/debugger/evaluate/compilation/CodeFragmentParameterAnalyzer.kt index 20a618e9d1c..5c23e7e9584 100644 --- a/idea/jvm-debugger/jvm-debugger-evaluation/src/org/jetbrains/kotlin/idea/debugger/evaluate/compilation/CodeFragmentParameterAnalyzer.kt +++ b/idea/jvm-debugger/jvm-debugger-evaluation/src/org/jetbrains/kotlin/idea/debugger/evaluate/compilation/CodeFragmentParameterAnalyzer.kt @@ -279,7 +279,7 @@ class CodeFragmentParameterAnalyzer( is SimpleFunctionDescriptor -> { val type = target.createFunctionType(target.builtIns, target.isSuspend) ?: return null parameters.getOrPut(target) { - Smart(Dumb(Kind.LOCAL_FUNCTION, target.name.asString()), type, target) + Smart(Dumb(Kind.LOCAL_FUNCTION, target.name.asString()), type, target.original) } } is ValueDescriptor -> { diff --git a/idea/testData/debugger/tinyApp/src/evaluate/multipleBreakpoints/localFun.kt b/idea/testData/debugger/tinyApp/src/evaluate/multipleBreakpoints/localFun.kt index 09b08ca9cdd..f48c102ff39 100644 --- a/idea/testData/debugger/tinyApp/src/evaluate/multipleBreakpoints/localFun.kt +++ b/idea/testData/debugger/tinyApp/src/evaluate/multipleBreakpoints/localFun.kt @@ -62,4 +62,11 @@ fun main(args: Array) { } myLocalFun7() + + fun myLocalFun8(): T = 1 as T + + // EXPRESSION: myLocalFun8() + // RESULT: 1: I + //Breakpoint! + myLocalFun8() } \ No newline at end of file diff --git a/idea/testData/debugger/tinyApp/src/evaluate/multipleBreakpoints/localFun.out b/idea/testData/debugger/tinyApp/src/evaluate/multipleBreakpoints/localFun.out index 535f06aa4a7..ffa4ae231ff 100644 --- a/idea/testData/debugger/tinyApp/src/evaluate/multipleBreakpoints/localFun.out +++ b/idea/testData/debugger/tinyApp/src/evaluate/multipleBreakpoints/localFun.out @@ -5,6 +5,7 @@ LineBreakpoint created at localFun.kt:34 LineBreakpoint created at localFun.kt:43 LineBreakpoint created at localFun.kt:54 LineBreakpoint created at localFun.kt:61 +LineBreakpoint created at localFun.kt:71 Run Java Connected to the target VM localFun.kt:9 @@ -21,6 +22,8 @@ localFun.kt:54 Compile bytecode for myLocalFun6() localFun.kt:61 Compile bytecode for myLocalFun6() + 1 +localFun.kt:71 +Compile bytecode for myLocalFun8() Disconnected from the target VM Process finished with exit code 0