Make isFromJava check work for SAM adapter extension descriptors (KT-21538)

Consider all callable descriptor in JavaClassDescriptor to be from Java.

This is used to check if smart step into should be intercepted by Kotlin
handler or delegated to Java.

 #KT-21538 Fixed
This commit is contained in:
Nikolay Krasko
2017-12-12 18:47:59 +03:00
parent 26413acf33
commit d6cface66f
5 changed files with 38 additions and 3 deletions
@@ -343,10 +343,10 @@ fun ClassDescriptor.hasRealKotlinSuperClassWithOverrideOf(
return false
}
// Util methods
val CallableMemberDescriptor.isFromJava: Boolean
get() = propertyIfAccessor.let { descriptor ->
(descriptor as? JavaCallableMemberDescriptor)?.containingDeclaration is JavaClassDescriptor
get() {
val descriptor = propertyIfAccessor
return descriptor.containingDeclaration is JavaClassDescriptor
}
fun CallableMemberDescriptor.isFromJavaOrBuiltins() = isFromJava || KotlinBuiltIns.isBuiltIn(this)
@@ -49,4 +49,9 @@ public class MyJavaClass {
public static class RawADerived extends RawA {
}
// Method with sam conversion for step into test
public void other(Runnable runnable) {
runnable.run();
}
}
@@ -0,0 +1,9 @@
package javaSamFunction
import forTests.MyJavaClass
fun main(args: Array<String>) {
val klass = MyJavaClass()
//Breakpoint!
klass.other { /* do nothing*/ }
}
@@ -0,0 +1,9 @@
LineBreakpoint created at javaSamFunction.kt:8
Run Java
Connected to the target VM
javaSamFunction.kt:8
MyJavaClass.java:55
resuming javaSamFunction.kt:8
Disconnected from the target VM
Process finished with exit code 0
@@ -62,6 +62,12 @@ public class KotlinSteppingTestGenerated extends AbstractKotlinSteppingTest {
doStepIntoTest(fileName);
}
@TestMetadata("javaSamFunction.kt")
public void testJavaSamFunction() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/stepping/stepIntoAndSmartStepInto/javaSamFunction.kt");
doStepIntoTest(fileName);
}
@TestMetadata("memberFunFromClass.kt")
public void testMemberFunFromClass() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/stepping/stepIntoAndSmartStepInto/memberFunFromClass.kt");
@@ -149,6 +155,12 @@ public class KotlinSteppingTestGenerated extends AbstractKotlinSteppingTest {
doSmartStepIntoTest(fileName);
}
@TestMetadata("javaSamFunction.kt")
public void testJavaSamFunction() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/stepping/stepIntoAndSmartStepInto/javaSamFunction.kt");
doSmartStepIntoTest(fileName);
}
@TestMetadata("memberFunFromClass.kt")
public void testMemberFunFromClass() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/stepping/stepIntoAndSmartStepInto/memberFunFromClass.kt");