Debugger: Allow super calls (KT-20560)
This commit is contained in:
@@ -63,7 +63,18 @@ class CodeFragmentCodegen private constructor(
|
|||||||
|
|
||||||
override fun generateBody() {
|
override fun generateBody() {
|
||||||
genConstructor()
|
genConstructor()
|
||||||
genMethod(classContext.intoFunction(methodDescriptor))
|
|
||||||
|
val methodContext = object : MethodContext(methodDescriptor, classContext.contextKind, classContext, null, false) {
|
||||||
|
override fun <D : CallableMemberDescriptor> getAccessorForSuperCallIfNeeded(
|
||||||
|
descriptor: D,
|
||||||
|
superCallTarget: ClassDescriptor?,
|
||||||
|
state: GenerationState
|
||||||
|
): D {
|
||||||
|
return descriptor
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
genMethod(methodContext)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun generateKotlinMetadataAnnotation() {
|
override fun generateKotlinMetadataAnnotation() {
|
||||||
|
|||||||
+10
-2
@@ -169,8 +169,16 @@ class CodeFragmentParameterAnalyzer(
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun visitSuperExpression(expression: KtSuperExpression, data: Unit?): Void {
|
override fun visitSuperExpression(expression: KtSuperExpression, data: Unit?): Void? {
|
||||||
throw EvaluateExceptionUtil.createEvaluateException("Evaluation of 'super' call expression is not supported")
|
val type = bindingContext[BindingContext.THIS_TYPE_FOR_SUPER_EXPRESSION, expression] ?: return null
|
||||||
|
val descriptor = type.constructor.declarationDescriptor as? ClassDescriptor ?: return null
|
||||||
|
|
||||||
|
parameters.getOrPut(descriptor) {
|
||||||
|
val name = descriptor.name.asString()
|
||||||
|
Smart(Dumb(Kind.DISPATCH_RECEIVER, "", "super@$name"), type, descriptor)
|
||||||
|
}
|
||||||
|
|
||||||
|
return null
|
||||||
}
|
}
|
||||||
}, Unit)
|
}, Unit)
|
||||||
|
|
||||||
|
|||||||
@@ -28,4 +28,4 @@ open class Base {
|
|||||||
// RESULT: Expecting an element; looking at ERROR_ELEMENT '(1,6) in /fragment.kt
|
// RESULT: Expecting an element; looking at ERROR_ELEMENT '(1,6) in /fragment.kt
|
||||||
|
|
||||||
// EXPRESSION: super.baseFun()
|
// EXPRESSION: super.baseFun()
|
||||||
// RESULT: Evaluation of 'super' call expression is not supported
|
// RESULT: VOID_VALUE
|
||||||
@@ -2,6 +2,7 @@ LineBreakpoint created at errors.kt:13
|
|||||||
Run Java
|
Run Java
|
||||||
Connected to the target VM
|
Connected to the target VM
|
||||||
errors.kt:13
|
errors.kt:13
|
||||||
|
Compile bytecode for super.baseFun()
|
||||||
Compile bytecode for prop += 1
|
Compile bytecode for prop += 1
|
||||||
prop2 +=2
|
prop2 +=2
|
||||||
prop + prop2
|
prop + prop2
|
||||||
|
|||||||
+29
@@ -0,0 +1,29 @@
|
|||||||
|
package superCallsCaptured
|
||||||
|
|
||||||
|
fun main() {
|
||||||
|
Bar().foo()
|
||||||
|
}
|
||||||
|
|
||||||
|
open class Foo {
|
||||||
|
open fun foo() = 5
|
||||||
|
}
|
||||||
|
|
||||||
|
class Bar : Foo() {
|
||||||
|
override fun foo(): Int {
|
||||||
|
block {
|
||||||
|
//Breakpoint!
|
||||||
|
val a = this@Bar
|
||||||
|
}
|
||||||
|
return 6
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun block(block: () -> Unit) {
|
||||||
|
block()
|
||||||
|
}
|
||||||
|
|
||||||
|
// EXPRESSION: foo()
|
||||||
|
// RESULT: 6: I
|
||||||
|
|
||||||
|
// EXPRESSION: super.foo()
|
||||||
|
// RESULT: 5: I
|
||||||
+9
@@ -0,0 +1,9 @@
|
|||||||
|
LineBreakpoint created at superCallsCaptured.kt:15
|
||||||
|
Run Java
|
||||||
|
Connected to the target VM
|
||||||
|
superCallsCaptured.kt:15
|
||||||
|
Compile bytecode for foo()
|
||||||
|
Compile bytecode for super.foo()
|
||||||
|
Disconnected from the target VM
|
||||||
|
|
||||||
|
Process finished with exit code 0
|
||||||
+22
@@ -0,0 +1,22 @@
|
|||||||
|
package superCallsSimple
|
||||||
|
|
||||||
|
fun main() {
|
||||||
|
Bar().foo()
|
||||||
|
}
|
||||||
|
|
||||||
|
open class Foo {
|
||||||
|
open fun foo() = 5
|
||||||
|
}
|
||||||
|
|
||||||
|
class Bar : Foo() {
|
||||||
|
override fun foo(): Int {
|
||||||
|
//Breakpoint!
|
||||||
|
return 6
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// EXPRESSION: foo()
|
||||||
|
// RESULT: 6: I
|
||||||
|
|
||||||
|
// EXPRESSION: super.foo()
|
||||||
|
// RESULT: 5: I
|
||||||
+9
@@ -0,0 +1,9 @@
|
|||||||
|
LineBreakpoint created at superCallsSimple.kt:14
|
||||||
|
Run Java
|
||||||
|
Connected to the target VM
|
||||||
|
superCallsSimple.kt:14
|
||||||
|
Compile bytecode for foo()
|
||||||
|
Compile bytecode for super.foo()
|
||||||
|
Disconnected from the target VM
|
||||||
|
|
||||||
|
Process finished with exit code 0
|
||||||
Generated
+10
@@ -396,6 +396,16 @@ public class KotlinEvaluateExpressionTestGenerated extends AbstractKotlinEvaluat
|
|||||||
runTest("idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/stdlib.kt");
|
runTest("idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/stdlib.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("superCallsCaptured.kt")
|
||||||
|
public void testSuperCallsCaptured() throws Exception {
|
||||||
|
runTest("idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/superCallsCaptured.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("superCallsSimple.kt")
|
||||||
|
public void testSuperCallsSimple() throws Exception {
|
||||||
|
runTest("idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/superCallsSimple.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("synchronizedBlock.kt")
|
@TestMetadata("synchronizedBlock.kt")
|
||||||
public void testSynchronizedBlock() throws Exception {
|
public void testSynchronizedBlock() throws Exception {
|
||||||
runTest("idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/synchronizedBlock.kt");
|
runTest("idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/synchronizedBlock.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user