Debugger: cannot call member extension in an object in Evaluate Expression
#KT-14822 Fixed
This commit is contained in:
+1
-1
@@ -115,7 +115,7 @@ class WrapParameterInWithReplacement(override val parameter: Parameter): WrapInW
|
||||
override fun copy(parameter: Parameter) = WrapParameterInWithReplacement(parameter)
|
||||
}
|
||||
|
||||
class WrapCompanionInWithReplacement(val descriptor: ClassDescriptor): WrapInWithReplacement() {
|
||||
class WrapObjectInWithReplacement(val descriptor: ClassDescriptor): WrapInWithReplacement() {
|
||||
override val argumentText: String
|
||||
get() = IdeDescriptorRenderers.SOURCE_CODE.renderClassifierName(descriptor)
|
||||
}
|
||||
|
||||
+4
-4
@@ -99,9 +99,9 @@ internal fun ExtractionData.inferParametersInfo(
|
||||
val dispatchReceiverDescriptor = (resolvedCall?.dispatchReceiver as? ImplicitReceiver)?.declarationDescriptor
|
||||
if (twoReceivers
|
||||
&& resolvedCall!!.extensionReceiver is ExpressionReceiver
|
||||
&& DescriptorUtils.isCompanionObject(dispatchReceiverDescriptor)) {
|
||||
&& DescriptorUtils.isObject(dispatchReceiverDescriptor)) {
|
||||
info.replacementMap.putValue(refInfo.resolveResult.originalRefExpr,
|
||||
WrapCompanionInWithReplacement(dispatchReceiverDescriptor as ClassDescriptor))
|
||||
WrapObjectInWithReplacement(dispatchReceiverDescriptor as ClassDescriptor))
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -188,8 +188,8 @@ private fun ExtractionData.extractReceiver(
|
||||
if (options.canWrapInWith
|
||||
&& resolvedCall != null
|
||||
&& resolvedCall.hasBothReceivers()
|
||||
&& DescriptorUtils.isCompanionObject(referencedClassifierDescriptor)) {
|
||||
info.replacementMap.putValue(originalRef, WrapCompanionInWithReplacement(referencedClassifierDescriptor as ClassDescriptor))
|
||||
&& DescriptorUtils.isObject(referencedClassifierDescriptor)) {
|
||||
info.replacementMap.putValue(originalRef, WrapObjectInWithReplacement(referencedClassifierDescriptor as ClassDescriptor))
|
||||
} else if (referencedClassifierDescriptor is ClassDescriptor) {
|
||||
info.replacementMap.putValue(originalRef, FqNameReplacement(originalDescriptor.getImportableDescriptor().fqNameSafe))
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
LineBreakpoint created at extensionMemberFunctionInObject.kt:14
|
||||
LineBreakpoint created at extensionMemberFunctionInObject.kt:20
|
||||
!JDK_HOME!\bin\java -agentlib:jdwp=transport=dt_socket,address=!HOST_NAME!:!HOST_PORT!,suspend=y,server=n -Dfile.encoding=!FILE_ENCODING! -classpath !OUTPUT_PATH!;!KOTLIN_RUNTIME!;!CUSTOM_LIBRARY!;!RT_JAR! extensionMemberFunctionInObject.ExtensionMemberFunctionInObjectKt
|
||||
Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
|
||||
extensionMemberFunctionInObject.kt:14
|
||||
Compile bytecode for "OK".baz()
|
||||
extensionMemberFunctionInObject.kt:20
|
||||
Compile bytecode for baz()
|
||||
Disconnected from the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
|
||||
|
||||
Process finished with exit code 0
|
||||
Vendored
+27
@@ -0,0 +1,27 @@
|
||||
package extensionMemberFunctionInObject
|
||||
|
||||
// KT-14822
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
Foo.bar()
|
||||
}
|
||||
|
||||
object Foo {
|
||||
fun bar() {
|
||||
// EXPRESSION: "OK".baz()
|
||||
// RESULT: 1: I
|
||||
//Breakpoint!
|
||||
"OK".baz()
|
||||
|
||||
with("OK") {
|
||||
// EXPRESSION: baz()
|
||||
// RESULT: 1: I
|
||||
//Breakpoint!
|
||||
baz()
|
||||
}
|
||||
}
|
||||
|
||||
fun String.baz(): Int {
|
||||
return 1
|
||||
}
|
||||
}
|
||||
+6
@@ -899,6 +899,12 @@ public class KotlinEvaluateExpressionTestGenerated extends AbstractKotlinEvaluat
|
||||
doMultipleBreakpointsTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("extensionMemberFunctionInObject.kt")
|
||||
public void testExtensionMemberFunctionInObject() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/evaluate/multipleBreakpoints/extensionMemberFunctionInObject.kt");
|
||||
doMultipleBreakpointsTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("extensionMemberProperty.kt")
|
||||
public void testExtensionMemberProperty() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/evaluate/multipleBreakpoints/extensionMemberProperty.kt");
|
||||
|
||||
Reference in New Issue
Block a user