Fix smart step into to Kotlin SAM adapter (KT-21538)

#KT-21538 Fixed
This commit is contained in:
Nikolay Krasko
2017-12-15 15:05:54 +03:00
parent adfee2086a
commit a3028beca9
4 changed files with 40 additions and 1 deletions
@@ -22,6 +22,7 @@ import com.intellij.util.Range
import com.intellij.util.SofterReference
import com.sun.jdi.Location
import org.jetbrains.kotlin.builtins.functions.FunctionInvokeDescriptor
import org.jetbrains.kotlin.codegen.SamCodegenUtil
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor.Kind.*
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptorIfAny
@@ -44,7 +45,9 @@ class KotlinBasicStepMethodFilter(
else -> targetDescriptor.name.asString()
}
private val _targetDescriptor = SofterReference(targetDescriptor)
private val _targetDescriptor = SofterReference(
(targetDescriptor as? FunctionDescriptor)?.let { SamCodegenUtil.getOriginalIfSamAdapter(it) } ?: targetDescriptor
)
override fun getCallingExpressionLines() = myCallingExpressionLines
@@ -0,0 +1,15 @@
package kotlinSamFunction
import forTests.MyJavaClass
class KotlinSubclass : MyJavaClass() {
override fun other(runnable: Runnable) {
super.other(runnable)
}
}
fun main(args: Array<String>) {
val klass = KotlinSubclass()
//Breakpoint!
klass.other { /* do nothing*/ }
}
@@ -0,0 +1,9 @@
LineBreakpoint created at kotlinSamFunction.kt:14
Run Java
Connected to the target VM
kotlinSamFunction.kt:14
kotlinSamFunction.kt:7
resuming kotlinSamFunction.kt:14
Disconnected from the target VM
Process finished with exit code 0
@@ -74,6 +74,12 @@ public class KotlinSteppingTestGenerated extends AbstractKotlinSteppingTest {
doStepIntoTest(fileName);
}
@TestMetadata("kotlinSamFunction.kt")
public void testKotlinSamFunction() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/stepping/stepIntoAndSmartStepInto/kotlinSamFunction.kt");
doStepIntoTest(fileName);
}
@TestMetadata("memberFunFromClass.kt")
public void testMemberFunFromClass() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/stepping/stepIntoAndSmartStepInto/memberFunFromClass.kt");
@@ -173,6 +179,12 @@ public class KotlinSteppingTestGenerated extends AbstractKotlinSteppingTest {
doSmartStepIntoTest(fileName);
}
@TestMetadata("kotlinSamFunction.kt")
public void testKotlinSamFunction() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/stepping/stepIntoAndSmartStepInto/kotlinSamFunction.kt");
doSmartStepIntoTest(fileName);
}
@TestMetadata("memberFunFromClass.kt")
public void testMemberFunFromClass() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/stepping/stepIntoAndSmartStepInto/memberFunFromClass.kt");