FIR JVM: correct signature conversion for array
#KT-43339 Fixed
This commit is contained in:
committed by
teamcityserver
parent
77ce5ea15d
commit
9a99af53ba
@@ -50,6 +50,7 @@ private fun StringBuilder.appendErasedType(typeRef: FirTypeRef) {
|
||||
klass.fqName?.let {
|
||||
append("L")
|
||||
append(it.asString().replace(".", "/"))
|
||||
append(";")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,14 +64,13 @@ private fun StringBuilder.appendErasedType(typeRef: FirTypeRef) {
|
||||
is JavaTypeParameter -> {
|
||||
val representative = classifier.upperBounds.firstOrNull { it.classifier is JavaClass }
|
||||
if (representative == null) {
|
||||
append("Ljava/lang/Object")
|
||||
append("Ljava/lang/Object;")
|
||||
} else {
|
||||
appendClass(representative.classifier as JavaClass)
|
||||
}
|
||||
}
|
||||
else -> return
|
||||
}
|
||||
append(";")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -92,19 +92,31 @@ private fun StringBuilder.appendConeType(coneType: ConeKotlinType) {
|
||||
(coneType as? ConeClassLikeType)?.let {
|
||||
val classId = it.lookupTag.classId
|
||||
if (classId.packageFqName.toString() == "kotlin") {
|
||||
PRIMITIVE_TYPE_SIGNATURE[classId.shortClassName.identifier]?.let {
|
||||
append(it)
|
||||
PRIMITIVE_TYPE_SIGNATURE[classId.shortClassName.identifier]?.let { signature ->
|
||||
append(signature)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun appendClassLikeType(type: ConeClassLikeType) {
|
||||
append("L")
|
||||
val classId = type.lookupTag.classId
|
||||
append(classId.packageFqName.asString().replace(".", "/"))
|
||||
append("/")
|
||||
append(classId.relativeClassName)
|
||||
if (classId.shortClassName.isSpecial) return
|
||||
if (classId.shortClassName.identifier == "Array") {
|
||||
append("[")
|
||||
type.typeArguments.forEach { typeArg ->
|
||||
when (typeArg) {
|
||||
ConeStarProjection -> append("*")
|
||||
is ConeKotlinTypeProjection -> appendConeType(typeArg.type)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
append("L")
|
||||
append(classId.packageFqName.asString().replace(".", "/"))
|
||||
append("/")
|
||||
append(classId.relativeClassName)
|
||||
append(";")
|
||||
}
|
||||
}
|
||||
|
||||
if (coneType is ConeClassErrorType) return
|
||||
@@ -117,21 +129,18 @@ private fun StringBuilder.appendConeType(coneType: ConeKotlinType) {
|
||||
it.coneType is ConeClassLikeType
|
||||
}
|
||||
if (representative == null || representative is FirImplicitNullableAnyTypeRef || representative is FirImplicitAnyTypeRef) {
|
||||
append("Ljava/lang/Object")
|
||||
append("Ljava/lang/Object;")
|
||||
} else {
|
||||
appendClassLikeType(representative.coneTypeUnsafe())
|
||||
}
|
||||
}
|
||||
is ConeDefinitelyNotNullType -> {
|
||||
appendConeType(coneType.original)
|
||||
return
|
||||
}
|
||||
is ConeFlexibleType -> {
|
||||
appendConeType(coneType.lowerBound)
|
||||
return
|
||||
}
|
||||
}
|
||||
append(";")
|
||||
}
|
||||
|
||||
private val unitClassId = ClassId.topLevel(FqName("kotlin.Unit"))
|
||||
|
||||
Reference in New Issue
Block a user