[FIR] add debug info to CME from bounds
^KT-59007 ^KT-60324
This commit is contained in:
committed by
Space Team
parent
2ab2f408f3
commit
3b9b9327a4
@@ -23,7 +23,9 @@ import org.jetbrains.kotlin.fir.scopes.jvm.computeJvmDescriptorRepresentation
|
||||
import org.jetbrains.kotlin.fir.scopes.processOverriddenFunctions
|
||||
import org.jetbrains.kotlin.fir.symbols.lazyResolveToPhase
|
||||
import org.jetbrains.kotlin.fir.types.*
|
||||
import org.jetbrains.kotlin.fir.utils.exceptions.withFirEntry
|
||||
import org.jetbrains.kotlin.name.StandardClassIds
|
||||
import org.jetbrains.kotlin.utils.exceptions.errorWithAttachment
|
||||
|
||||
class JavaOverrideChecker internal constructor(
|
||||
private val session: FirSession,
|
||||
@@ -148,7 +150,16 @@ class JavaOverrideChecker internal constructor(
|
||||
|
||||
private fun Collection<FirTypeParameterRef>.buildErasure() = associate {
|
||||
val symbol = it.symbol
|
||||
val firstBound = symbol.fir.bounds.first() // Note that in Java type parameter typed arguments always erased to first bound
|
||||
val firstBound = symbol.fir.bounds.firstOrNull() // Note that in Java type parameter typed arguments always erased to first bound
|
||||
if (firstBound == null) {
|
||||
errorWithAttachment("Bound element is not found") {
|
||||
withFirEntry("typeParameterRef", it)
|
||||
val firTypeParameter = it.symbol.fir
|
||||
withFirEntry("typeParameter", firTypeParameter)
|
||||
withFirEntry("containingDeclaration", firTypeParameter.containingDeclarationSymbol.fir)
|
||||
}
|
||||
}
|
||||
|
||||
symbol to firstBound.toConeKotlinTypeProbablyFlexible(session, javaTypeParameterStack)
|
||||
}
|
||||
|
||||
|
||||
@@ -14,11 +14,13 @@ import org.jetbrains.kotlin.fir.types.*
|
||||
import org.jetbrains.kotlin.fir.types.impl.FirImplicitAnyTypeRef
|
||||
import org.jetbrains.kotlin.fir.types.impl.FirImplicitNullableAnyTypeRef
|
||||
import org.jetbrains.kotlin.fir.types.jvm.FirJavaTypeRef
|
||||
import org.jetbrains.kotlin.fir.utils.exceptions.withFirEntry
|
||||
import org.jetbrains.kotlin.load.java.structure.JavaPrimitiveType
|
||||
import org.jetbrains.kotlin.load.kotlin.SignatureBuildingComponents
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.StandardClassIds
|
||||
import org.jetbrains.kotlin.utils.exceptions.errorWithAttachment
|
||||
|
||||
fun FirFunction.computeJvmSignature(typeConversion: (FirTypeRef) -> ConeKotlinType? = FirTypeRef::coneTypeSafe): String? {
|
||||
val containingClass = containingClassLookupTag() ?: return null
|
||||
@@ -45,7 +47,25 @@ fun FirFunction.computeJvmDescriptor(
|
||||
|
||||
append("(")
|
||||
for (parameter in valueParameters) {
|
||||
typeConversion(parameter.returnTypeRef)?.let { appendConeType(it, typeConversion, mutableSetOf()) }
|
||||
typeConversion(parameter.returnTypeRef)?.let { coneType ->
|
||||
try {
|
||||
appendConeType(coneType, typeConversion, mutableSetOf())
|
||||
} catch (e: ConcurrentModificationException) {
|
||||
errorWithAttachment("CME from appendConeType", cause = e) {
|
||||
withEntry("typeClass", coneType::class.simpleName)
|
||||
withEntry("type", coneType) {
|
||||
try {
|
||||
it.renderForDebugging()
|
||||
} catch (e: Throwable) {
|
||||
"Render is failed due to ${e::class}"
|
||||
}
|
||||
}
|
||||
|
||||
withFirEntry("parameter", parameter)
|
||||
withFirEntry("function", this@computeJvmDescriptor)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
append(")")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user