Debugger: Handle case when we can't calculate the anonymous class name gracefully (EA-141202)

This commit is contained in:
Yan Zhulanow
2019-07-24 18:52:01 +09:00
parent 0f568a395f
commit 527df35bf3
2 changed files with 11 additions and 6 deletions
@@ -24,7 +24,6 @@ import com.intellij.psi.util.PsiTreeUtil
import com.sun.jdi.AbsentInformationException
import com.sun.jdi.ObjectCollectedException
import com.sun.jdi.ReferenceType
import org.jetbrains.kotlin.codegen.binding.CodegenBinding.asmTypeForAnonymousClass
import org.jetbrains.kotlin.codegen.binding.CodegenBinding.asmTypeForAnonymousClassOrNull
import org.jetbrains.kotlin.descriptors.ScriptDescriptor
import org.jetbrains.kotlin.fileClasses.JvmFileClassUtil
@@ -222,15 +221,19 @@ class DebuggerClassNameProvider(
is KtFunctionLiteral -> {
val typeMapper = KotlinDebuggerCaches.getOrCreateTypeMapper(element)
val nonInlinedLambdaClassName = runReadAction {
asmTypeForAnonymousClass(typeMapper.bindingContext, element).internalName.toJdiName()
val names = runReadAction {
val name = asmTypeForAnonymousClassOrNull(typeMapper.bindingContext, element)?.internalName?.toJdiName()
if (name != null) Cached(name) else EMPTY
}
if (!alwaysReturnLambdaParentClass && !InlineUtil.isInlinedArgument(element, typeMapper.bindingContext, true)) {
return Cached(nonInlinedLambdaClassName)
if (!names.isEmpty()
&& !alwaysReturnLambdaParentClass
&& !InlineUtil.isInlinedArgument(element, typeMapper.bindingContext, true)
) {
return names
}
Cached(nonInlinedLambdaClassName) + getOuterClassNamesForElement(element.relevantParentInReadAction)
names + getOuterClassNamesForElement(element.relevantParentInReadAction)
}
else -> getOuterClassNamesForElement(element.relevantParentInReadAction)
}
@@ -229,6 +229,8 @@ class KotlinDebuggerCaches(project: Project) {
fun NonCached(classNames: List<String>) = ComputedClassNames(classNames, false)
}
fun isEmpty() = classNames.isEmpty()
fun distinct() = ComputedClassNames(classNames.distinct(), shouldBeCached)
operator fun plus(other: ComputedClassNames) = ComputedClassNames(