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 {
|
klass.fqName?.let {
|
||||||
append("L")
|
append("L")
|
||||||
append(it.asString().replace(".", "/"))
|
append(it.asString().replace(".", "/"))
|
||||||
|
append(";")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,14 +64,13 @@ private fun StringBuilder.appendErasedType(typeRef: FirTypeRef) {
|
|||||||
is JavaTypeParameter -> {
|
is JavaTypeParameter -> {
|
||||||
val representative = classifier.upperBounds.firstOrNull { it.classifier is JavaClass }
|
val representative = classifier.upperBounds.firstOrNull { it.classifier is JavaClass }
|
||||||
if (representative == null) {
|
if (representative == null) {
|
||||||
append("Ljava/lang/Object")
|
append("Ljava/lang/Object;")
|
||||||
} else {
|
} else {
|
||||||
appendClass(representative.classifier as JavaClass)
|
appendClass(representative.classifier as JavaClass)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else -> return
|
else -> return
|
||||||
}
|
}
|
||||||
append(";")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -92,19 +92,31 @@ private fun StringBuilder.appendConeType(coneType: ConeKotlinType) {
|
|||||||
(coneType as? ConeClassLikeType)?.let {
|
(coneType as? ConeClassLikeType)?.let {
|
||||||
val classId = it.lookupTag.classId
|
val classId = it.lookupTag.classId
|
||||||
if (classId.packageFqName.toString() == "kotlin") {
|
if (classId.packageFqName.toString() == "kotlin") {
|
||||||
PRIMITIVE_TYPE_SIGNATURE[classId.shortClassName.identifier]?.let {
|
PRIMITIVE_TYPE_SIGNATURE[classId.shortClassName.identifier]?.let { signature ->
|
||||||
append(it)
|
append(signature)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun appendClassLikeType(type: ConeClassLikeType) {
|
fun appendClassLikeType(type: ConeClassLikeType) {
|
||||||
append("L")
|
|
||||||
val classId = type.lookupTag.classId
|
val classId = type.lookupTag.classId
|
||||||
append(classId.packageFqName.asString().replace(".", "/"))
|
if (classId.shortClassName.isSpecial) return
|
||||||
append("/")
|
if (classId.shortClassName.identifier == "Array") {
|
||||||
append(classId.relativeClassName)
|
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
|
if (coneType is ConeClassErrorType) return
|
||||||
@@ -117,21 +129,18 @@ private fun StringBuilder.appendConeType(coneType: ConeKotlinType) {
|
|||||||
it.coneType is ConeClassLikeType
|
it.coneType is ConeClassLikeType
|
||||||
}
|
}
|
||||||
if (representative == null || representative is FirImplicitNullableAnyTypeRef || representative is FirImplicitAnyTypeRef) {
|
if (representative == null || representative is FirImplicitNullableAnyTypeRef || representative is FirImplicitAnyTypeRef) {
|
||||||
append("Ljava/lang/Object")
|
append("Ljava/lang/Object;")
|
||||||
} else {
|
} else {
|
||||||
appendClassLikeType(representative.coneTypeUnsafe())
|
appendClassLikeType(representative.coneTypeUnsafe())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
is ConeDefinitelyNotNullType -> {
|
is ConeDefinitelyNotNullType -> {
|
||||||
appendConeType(coneType.original)
|
appendConeType(coneType.original)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
is ConeFlexibleType -> {
|
is ConeFlexibleType -> {
|
||||||
appendConeType(coneType.lowerBound)
|
appendConeType(coneType.lowerBound)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
append(";")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private val unitClassId = ClassId.topLevel(FqName("kotlin.Unit"))
|
private val unitClassId = ClassId.topLevel(FqName("kotlin.Unit"))
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
// !LANGUAGE: -ForbidReferencingToUnderscoreNamedParameterOfCatchBlock
|
// !LANGUAGE: -ForbidReferencingToUnderscoreNamedParameterOfCatchBlock
|
||||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNUSED_ANONYMOUS_PARAMETER -UNUSED_EXPRESSION
|
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNUSED_ANONYMOUS_PARAMETER -UNUSED_EXPRESSION
|
||||||
|
// FULL_JDK
|
||||||
|
|
||||||
fun foo() {
|
fun foo() {
|
||||||
try {
|
try {
|
||||||
TODO()
|
TODO()
|
||||||
} catch (_: Exception) {
|
} catch (_: Exception) {
|
||||||
`_`.<!UNRESOLVED_REFERENCE!>stackTrace<!>
|
`_`.stackTrace
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
TODO()
|
TODO()
|
||||||
@@ -27,7 +28,7 @@ fun foo() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (_: Exception) {
|
} catch (_: Exception) {
|
||||||
`_`.<!UNRESOLVED_REFERENCE!>stackTrace<!>
|
`_`.stackTrace
|
||||||
val y1 = _
|
val y1 = _
|
||||||
val y2 = (`_`)
|
val y2 = (`_`)
|
||||||
}
|
}
|
||||||
@@ -37,21 +38,21 @@ fun foo() {
|
|||||||
try {
|
try {
|
||||||
TODO()
|
TODO()
|
||||||
} catch (x: Exception) {
|
} catch (x: Exception) {
|
||||||
`_`.<!UNRESOLVED_REFERENCE!>stackTrace<!>
|
`_`.stackTrace
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val boo1 = { `_`: Exception ->
|
val boo1 = { `_`: Exception ->
|
||||||
try {
|
try {
|
||||||
TODO()
|
TODO()
|
||||||
} catch (x: Exception) {
|
} catch (x: Exception) {
|
||||||
`_`.<!UNRESOLVED_REFERENCE!>stackTrace<!>
|
`_`.stackTrace
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val boo2 = { _: Exception ->
|
val boo2 = { _: Exception ->
|
||||||
try {
|
try {
|
||||||
TODO()
|
TODO()
|
||||||
} catch (x: Exception) {
|
} catch (x: Exception) {
|
||||||
`_`.<!UNRESOLVED_REFERENCE!>stackTrace<!>
|
`_`.stackTrace
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
// !LANGUAGE: -ForbidReferencingToUnderscoreNamedParameterOfCatchBlock
|
// !LANGUAGE: -ForbidReferencingToUnderscoreNamedParameterOfCatchBlock
|
||||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNUSED_ANONYMOUS_PARAMETER -UNUSED_EXPRESSION
|
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNUSED_ANONYMOUS_PARAMETER -UNUSED_EXPRESSION
|
||||||
|
// FULL_JDK
|
||||||
|
|
||||||
fun foo() {
|
fun foo() {
|
||||||
try {
|
try {
|
||||||
|
|||||||
Vendored
+6
-5
@@ -1,11 +1,12 @@
|
|||||||
// !LANGUAGE: +ForbidReferencingToUnderscoreNamedParameterOfCatchBlock
|
// !LANGUAGE: +ForbidReferencingToUnderscoreNamedParameterOfCatchBlock
|
||||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNUSED_ANONYMOUS_PARAMETER -UNUSED_EXPRESSION
|
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNUSED_ANONYMOUS_PARAMETER -UNUSED_EXPRESSION
|
||||||
|
// FULL_JDK
|
||||||
|
|
||||||
fun foo() {
|
fun foo() {
|
||||||
try {
|
try {
|
||||||
TODO()
|
TODO()
|
||||||
} catch (_: Exception) {
|
} catch (_: Exception) {
|
||||||
`_`.<!UNRESOLVED_REFERENCE!>stackTrace<!>
|
`_`.stackTrace
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
TODO()
|
TODO()
|
||||||
@@ -27,7 +28,7 @@ fun foo() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (_: Exception) {
|
} catch (_: Exception) {
|
||||||
`_`.<!UNRESOLVED_REFERENCE!>stackTrace<!>
|
`_`.stackTrace
|
||||||
val y1 = _
|
val y1 = _
|
||||||
val y2 = (`_`)
|
val y2 = (`_`)
|
||||||
}
|
}
|
||||||
@@ -37,21 +38,21 @@ fun foo() {
|
|||||||
try {
|
try {
|
||||||
TODO()
|
TODO()
|
||||||
} catch (x: Exception) {
|
} catch (x: Exception) {
|
||||||
`_`.<!UNRESOLVED_REFERENCE!>stackTrace<!>
|
`_`.stackTrace
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val boo1 = { `_`: Exception ->
|
val boo1 = { `_`: Exception ->
|
||||||
try {
|
try {
|
||||||
TODO()
|
TODO()
|
||||||
} catch (x: Exception) {
|
} catch (x: Exception) {
|
||||||
`_`.<!UNRESOLVED_REFERENCE!>stackTrace<!>
|
`_`.stackTrace
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val boo2 = { _: Exception ->
|
val boo2 = { _: Exception ->
|
||||||
try {
|
try {
|
||||||
TODO()
|
TODO()
|
||||||
} catch (x: Exception) {
|
} catch (x: Exception) {
|
||||||
`_`.<!UNRESOLVED_REFERENCE!>stackTrace<!>
|
`_`.stackTrace
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
@@ -1,5 +1,6 @@
|
|||||||
// !LANGUAGE: +ForbidReferencingToUnderscoreNamedParameterOfCatchBlock
|
// !LANGUAGE: +ForbidReferencingToUnderscoreNamedParameterOfCatchBlock
|
||||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNUSED_ANONYMOUS_PARAMETER -UNUSED_EXPRESSION
|
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNUSED_ANONYMOUS_PARAMETER -UNUSED_EXPRESSION
|
||||||
|
// FULL_JDK
|
||||||
|
|
||||||
fun foo() {
|
fun foo() {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -2,4 +2,7 @@ FILE fqName:<root> fileName:/throwableStackTrace.kt
|
|||||||
FUN name:foo visibility:public modality:FINAL <> (t:kotlin.Throwable) returnType:kotlin.Unit
|
FUN name:foo visibility:public modality:FINAL <> (t:kotlin.Throwable) returnType:kotlin.Unit
|
||||||
VALUE_PARAMETER name:t index:0 type:kotlin.Throwable
|
VALUE_PARAMETER name:t index:0 type:kotlin.Throwable
|
||||||
BLOCK_BODY
|
BLOCK_BODY
|
||||||
ERROR_CALL 'Unresolved reference: R|kotlin/stackTrace|' type=IrErrorType
|
CALL 'public open fun setStackTrace (p0: kotlin.Array<out java.lang.StackTraceElement?>?): kotlin.Unit declared in java.lang.Throwable' type=kotlin.Unit origin=EQ
|
||||||
|
$this: GET_VAR 't: kotlin.Throwable declared in <root>.foo' type=kotlin.Throwable origin=null
|
||||||
|
p0: CALL 'public open fun getStackTrace (): kotlin.Array<out java.lang.StackTraceElement?>? declared in java.lang.Throwable' type=kotlin.Array<out java.lang.StackTraceElement?>? origin=GET_PROPERTY
|
||||||
|
$this: GET_VAR 't: kotlin.Throwable declared in <root>.foo' type=kotlin.Throwable origin=null
|
||||||
|
|||||||
Reference in New Issue
Block a user