Log name of the class caused LinkageError in SyntheticResolveExtension
#EA-120641: Now it is unclear which extension caused AbstractMethodError
This commit is contained in:
+49
-7
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.resolve.extensions
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger
|
||||
import com.intellij.openapi.project.Project
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
||||
@@ -36,29 +37,50 @@ interface SyntheticResolveExtension {
|
||||
companion object : ProjectExtensionDescriptor<SyntheticResolveExtension>(
|
||||
"org.jetbrains.kotlin.syntheticResolveExtension", SyntheticResolveExtension::class.java
|
||||
) {
|
||||
private val logger = Logger.getInstance(this::class.java)
|
||||
|
||||
private inline fun <T : Any, R> withLinkageErrorLogger(receiver: T, block: T.() -> R): R {
|
||||
try {
|
||||
return receiver.block()
|
||||
} catch (e: LinkageError) {
|
||||
logger.error("${receiver::class.java.name} caused LinkageError", e)
|
||||
throw e
|
||||
}
|
||||
}
|
||||
|
||||
fun getInstance(project: Project): SyntheticResolveExtension {
|
||||
val instances = getInstances(project)
|
||||
if (instances.size == 1) return instances.single()
|
||||
// return list combiner here
|
||||
return object : SyntheticResolveExtension {
|
||||
override fun getSyntheticNestedClassNames(thisDescriptor: ClassDescriptor): List<Name> =
|
||||
instances.flatMap { it.getSyntheticNestedClassNames(thisDescriptor) }
|
||||
instances.flatMap { withLinkageErrorLogger(it) { getSyntheticNestedClassNames(thisDescriptor) } }
|
||||
|
||||
override fun getSyntheticFunctionNames(thisDescriptor: ClassDescriptor): List<Name> =
|
||||
instances.flatMap { it.getSyntheticFunctionNames(thisDescriptor) }
|
||||
instances.flatMap { withLinkageErrorLogger(it) { getSyntheticFunctionNames(thisDescriptor) } }
|
||||
|
||||
override fun generateSyntheticClasses(
|
||||
thisDescriptor: ClassDescriptor, name: Name,
|
||||
ctx: LazyClassContext, declarationProvider: ClassMemberDeclarationProvider,
|
||||
result: MutableSet<ClassDescriptor>
|
||||
) =
|
||||
instances.forEach { it.generateSyntheticClasses(thisDescriptor, name, ctx, declarationProvider, result) }
|
||||
instances.forEach {
|
||||
withLinkageErrorLogger(it) {
|
||||
generateSyntheticClasses(
|
||||
thisDescriptor,
|
||||
name,
|
||||
ctx,
|
||||
declarationProvider,
|
||||
result
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getSyntheticCompanionObjectNameIfNeeded(thisDescriptor: ClassDescriptor): Name? =
|
||||
instances.firstNotNullResult { it.getSyntheticCompanionObjectNameIfNeeded(thisDescriptor) }
|
||||
instances.firstNotNullResult { withLinkageErrorLogger(it) { getSyntheticCompanionObjectNameIfNeeded(thisDescriptor) } }
|
||||
|
||||
override fun addSyntheticSupertypes(thisDescriptor: ClassDescriptor, supertypes: MutableList<KotlinType>) =
|
||||
instances.forEach { it.addSyntheticSupertypes(thisDescriptor, supertypes) }
|
||||
instances.forEach { withLinkageErrorLogger(it) { addSyntheticSupertypes(thisDescriptor, supertypes) } }
|
||||
|
||||
// todo revert
|
||||
override fun generateSyntheticMethods(
|
||||
@@ -67,7 +89,17 @@ interface SyntheticResolveExtension {
|
||||
fromSupertypes: List<SimpleFunctionDescriptor>,
|
||||
result: MutableCollection<SimpleFunctionDescriptor>
|
||||
) =
|
||||
instances.forEach { it.generateSyntheticMethods(thisDescriptor, name, bindingContext, fromSupertypes, result) }
|
||||
instances.forEach {
|
||||
withLinkageErrorLogger(it) {
|
||||
generateSyntheticMethods(
|
||||
thisDescriptor,
|
||||
name,
|
||||
bindingContext,
|
||||
fromSupertypes,
|
||||
result
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun generateSyntheticProperties(
|
||||
thisDescriptor: ClassDescriptor, name: Name,
|
||||
@@ -75,7 +107,17 @@ interface SyntheticResolveExtension {
|
||||
fromSupertypes: ArrayList<PropertyDescriptor>,
|
||||
result: MutableSet<PropertyDescriptor>
|
||||
) =
|
||||
instances.forEach { it.generateSyntheticProperties(thisDescriptor, name, bindingContext, fromSupertypes, result) }
|
||||
instances.forEach {
|
||||
withLinkageErrorLogger(it) {
|
||||
generateSyntheticProperties(
|
||||
thisDescriptor,
|
||||
name,
|
||||
bindingContext,
|
||||
fromSupertypes,
|
||||
result
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user