Debugger: Classes for callable references should be treated as synthetic
This commit is contained in:
+24
-5
@@ -17,21 +17,25 @@
|
|||||||
package org.jetbrains.kotlin.idea.debugger.filter
|
package org.jetbrains.kotlin.idea.debugger.filter
|
||||||
|
|
||||||
import com.intellij.debugger.engine.SyntheticTypeComponentProvider
|
import com.intellij.debugger.engine.SyntheticTypeComponentProvider
|
||||||
import com.sun.jdi.AbsentInformationException
|
import com.sun.jdi.*
|
||||||
import com.sun.jdi.ClassType
|
|
||||||
import com.sun.jdi.Method
|
|
||||||
import com.sun.jdi.TypeComponent
|
|
||||||
import org.jetbrains.kotlin.load.java.JvmAbi
|
import org.jetbrains.kotlin.load.java.JvmAbi
|
||||||
import org.jetbrains.kotlin.name.FqNameUnsafe
|
import org.jetbrains.kotlin.name.FqNameUnsafe
|
||||||
import org.jetbrains.org.objectweb.asm.Opcodes
|
import org.jetbrains.org.objectweb.asm.Opcodes
|
||||||
|
import kotlin.jvm.internal.FunctionReference
|
||||||
|
import kotlin.jvm.internal.PropertyReference
|
||||||
|
|
||||||
class KotlinSyntheticTypeComponentProvider: SyntheticTypeComponentProvider {
|
class KotlinSyntheticTypeComponentProvider: SyntheticTypeComponentProvider {
|
||||||
override fun isSynthetic(typeComponent: TypeComponent?): Boolean {
|
override fun isSynthetic(typeComponent: TypeComponent?): Boolean {
|
||||||
if (typeComponent !is Method) return false
|
if (typeComponent !is Method) return false
|
||||||
|
|
||||||
val typeName = typeComponent.declaringType().name()
|
val containingType = typeComponent.declaringType()
|
||||||
|
val typeName = containingType.name()
|
||||||
if (!FqNameUnsafe.isValid(typeName)) return false
|
if (!FqNameUnsafe.isValid(typeName)) return false
|
||||||
|
|
||||||
|
if (containingType.isCallableReferenceSyntheticClass()) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (typeComponent.isDelegateToDefaultInterfaceImpl()) return true
|
if (typeComponent.isDelegateToDefaultInterfaceImpl()) return true
|
||||||
|
|
||||||
@@ -51,6 +55,21 @@ class KotlinSyntheticTypeComponentProvider: SyntheticTypeComponentProvider {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private tailrec fun ReferenceType?.isCallableReferenceSyntheticClass(): Boolean {
|
||||||
|
if (this !is ClassType) return false
|
||||||
|
val superClass = this.superclass() ?: return false
|
||||||
|
val superClassName = superClass.name()
|
||||||
|
if (superClassName == PropertyReference::class.java.name || superClassName == FunctionReference::class.java.name) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// The direct supertype may be PropertyReference0 or something
|
||||||
|
return if (superClassName.startsWith("kotlin.jvm.internal."))
|
||||||
|
superClass.isCallableReferenceSyntheticClass()
|
||||||
|
else
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
private fun Method.isDelegateToDefaultInterfaceImpl(): Boolean {
|
private fun Method.isDelegateToDefaultInterfaceImpl(): Boolean {
|
||||||
if (allLineLocations().size != 1) return false
|
if (allLineLocations().size != 1) return false
|
||||||
if (!virtualMachine().canGetBytecodes()) return false
|
if (!virtualMachine().canGetBytecodes()) return false
|
||||||
|
|||||||
Reference in New Issue
Block a user