Debugger: Fix evaluation of function declarations with expression bodies (KT-32704)
Before this commit, the substituted FunctionDescriptor didn't have a source element. As a result, 'CodeFragmentParameterAnalyzer.isCodeFragmentDeclaration' failed to recognize such a descriptor as fragment-local, and it was erroneously captured.
This commit is contained in:
+6
-1
@@ -328,7 +328,12 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
|
||||
if (originalSubstitutor.isEmpty()) {
|
||||
return this;
|
||||
}
|
||||
return newCopyBuilder(originalSubstitutor).setOriginal(getOriginal()).setJustForTypeSubstitution(true).build();
|
||||
|
||||
return newCopyBuilder(originalSubstitutor)
|
||||
.setOriginal(getOriginal())
|
||||
.setPreserveSourceElement()
|
||||
.setJustForTypeSubstitution(true)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
+5
@@ -190,6 +190,11 @@ public class KotlinEvaluateExpressionTestGenerated extends AbstractKotlinEvaluat
|
||||
runTest("idea/jvm-debugger/jvm-debugger-test/testData/evaluation/singleBreakpoint/functionDeclaration.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("functionWithBodyExpression.kt")
|
||||
public void testFunctionWithBodyExpression() throws Exception {
|
||||
runTest("idea/jvm-debugger/jvm-debugger-test/testData/evaluation/singleBreakpoint/functionWithBodyExpression.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("genericCrossinlineArgument.kt")
|
||||
public void testGenericCrossinlineArgument() throws Exception {
|
||||
runTest("idea/jvm-debugger/jvm-debugger-test/testData/evaluation/singleBreakpoint/genericCrossinlineArgument.kt");
|
||||
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
package functionWithBodyExpression
|
||||
|
||||
fun main() {
|
||||
//Breakpoint!
|
||||
val a = 5
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
fun f2() = "f2"
|
||||
f2()
|
||||
|
||||
// RESULT: "f2": Ljava/lang/String;
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
LineBreakpoint created at functionWithBodyExpression.kt:5
|
||||
Run Java
|
||||
Connected to the target VM
|
||||
functionWithBodyExpression.kt:5
|
||||
Compile bytecode for fun f2() = "f2"
|
||||
f2()
|
||||
|
||||
// RESULT: "f2": Ljava/lang/String;
|
||||
Disconnected from the target VM
|
||||
|
||||
Process finished with exit code 0
|
||||
@@ -2,8 +2,8 @@
|
||||
<html>
|
||||
Overload resolution ambiguity. All these functions match.
|
||||
<ul>
|
||||
<li><b>public</b> <b>fun</b> <`T> foo(b: a.b.String, t: ???): Unit <i>defined in</i> a.b</li>
|
||||
<li><b>public</b> <b>fun</b> <`T> foo(b: a.b.String, t: ???): Unit <i>defined in</i> a.b <i>in file</i> overloadResolutionAmbiguityHtml.kt</li>
|
||||
<li><b>public</b> <b>fun</b> foo(i: Int): Unit <i>defined in</i> a.b <i>in file</i> overloadResolutionAmbiguityHtml.kt</li>
|
||||
<li><b>public</b> <b>fun</b> <`T> foo(a: kotlin.String, t: ???): Unit <i>defined in</i> a.b</li>
|
||||
<li><b>public</b> <b>fun</b> <`T> foo(a: kotlin.String, t: ???): Unit <i>defined in</i> a.b <i>in file</i> overloadResolutionAmbiguityHtml.kt</li>
|
||||
</ul>
|
||||
</html>
|
||||
@@ -1,5 +1,5 @@
|
||||
<!-- overloadResolutionAmbiguityTxt1 -->
|
||||
Overload resolution ambiguity:
|
||||
public fun <T> foo(b: a.b.String, t: ???): Unit defined in a.b
|
||||
public fun <T> foo(b: a.b.String, t: ???): Unit defined in a.b in file overloadResolutionAmbiguityTxt.kt
|
||||
public fun foo(i: Int): Unit defined in a.b in file overloadResolutionAmbiguityTxt.kt
|
||||
public fun <T> foo(a: kotlin.String, t: ???): Unit defined in a.b
|
||||
public fun <T> foo(a: kotlin.String, t: ???): Unit defined in a.b in file overloadResolutionAmbiguityTxt.kt
|
||||
Reference in New Issue
Block a user