diff --git a/compiler/fir/jvm/src/org/jetbrains/kotlin/fir/scopes/jvm/DescriptorUtils.kt b/compiler/fir/jvm/src/org/jetbrains/kotlin/fir/scopes/jvm/DescriptorUtils.kt index 26b6e783c81..f2f7b8fdc6c 100644 --- a/compiler/fir/jvm/src/org/jetbrains/kotlin/fir/scopes/jvm/DescriptorUtils.kt +++ b/compiler/fir/jvm/src/org/jetbrains/kotlin/fir/scopes/jvm/DescriptorUtils.kt @@ -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")) diff --git a/compiler/testData/diagnostics/tests/resolve/underscoreInCatchBlock.fir.kt b/compiler/testData/diagnostics/tests/resolve/underscoreInCatchBlock.fir.kt index b18df6f1a3a..805c7ebac3c 100644 --- a/compiler/testData/diagnostics/tests/resolve/underscoreInCatchBlock.fir.kt +++ b/compiler/testData/diagnostics/tests/resolve/underscoreInCatchBlock.fir.kt @@ -1,11 +1,12 @@ // !LANGUAGE: -ForbidReferencingToUnderscoreNamedParameterOfCatchBlock // !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNUSED_ANONYMOUS_PARAMETER -UNUSED_EXPRESSION +// FULL_JDK fun foo() { try { TODO() } catch (_: Exception) { - `_`.stackTrace + `_`.stackTrace } try { TODO() @@ -27,7 +28,7 @@ fun foo() { } } } catch (_: Exception) { - `_`.stackTrace + `_`.stackTrace val y1 = _ val y2 = (`_`) } @@ -37,21 +38,21 @@ fun foo() { try { TODO() } catch (x: Exception) { - `_`.stackTrace + `_`.stackTrace } } val boo1 = { `_`: Exception -> try { TODO() } catch (x: Exception) { - `_`.stackTrace + `_`.stackTrace } } val boo2 = { _: Exception -> try { TODO() } catch (x: Exception) { - `_`.stackTrace + `_`.stackTrace } } } diff --git a/compiler/testData/diagnostics/tests/resolve/underscoreInCatchBlock.kt b/compiler/testData/diagnostics/tests/resolve/underscoreInCatchBlock.kt index 6d323b996dd..fffe6459de9 100644 --- a/compiler/testData/diagnostics/tests/resolve/underscoreInCatchBlock.kt +++ b/compiler/testData/diagnostics/tests/resolve/underscoreInCatchBlock.kt @@ -1,5 +1,6 @@ // !LANGUAGE: -ForbidReferencingToUnderscoreNamedParameterOfCatchBlock // !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNUSED_ANONYMOUS_PARAMETER -UNUSED_EXPRESSION +// FULL_JDK fun foo() { try { diff --git a/compiler/testData/diagnostics/tests/resolve/underscoreInCatchBlockWithEnabledFeature.fir.kt b/compiler/testData/diagnostics/tests/resolve/underscoreInCatchBlockWithEnabledFeature.fir.kt index 8b52f9445b3..1bb2a00e099 100644 --- a/compiler/testData/diagnostics/tests/resolve/underscoreInCatchBlockWithEnabledFeature.fir.kt +++ b/compiler/testData/diagnostics/tests/resolve/underscoreInCatchBlockWithEnabledFeature.fir.kt @@ -1,11 +1,12 @@ // !LANGUAGE: +ForbidReferencingToUnderscoreNamedParameterOfCatchBlock // !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNUSED_ANONYMOUS_PARAMETER -UNUSED_EXPRESSION +// FULL_JDK fun foo() { try { TODO() } catch (_: Exception) { - `_`.stackTrace + `_`.stackTrace } try { TODO() @@ -27,7 +28,7 @@ fun foo() { } } } catch (_: Exception) { - `_`.stackTrace + `_`.stackTrace val y1 = _ val y2 = (`_`) } @@ -37,21 +38,21 @@ fun foo() { try { TODO() } catch (x: Exception) { - `_`.stackTrace + `_`.stackTrace } } val boo1 = { `_`: Exception -> try { TODO() } catch (x: Exception) { - `_`.stackTrace + `_`.stackTrace } } val boo2 = { _: Exception -> try { TODO() } catch (x: Exception) { - `_`.stackTrace + `_`.stackTrace } } } diff --git a/compiler/testData/diagnostics/tests/resolve/underscoreInCatchBlockWithEnabledFeature.kt b/compiler/testData/diagnostics/tests/resolve/underscoreInCatchBlockWithEnabledFeature.kt index 828d1a518e1..777905cdefb 100644 --- a/compiler/testData/diagnostics/tests/resolve/underscoreInCatchBlockWithEnabledFeature.kt +++ b/compiler/testData/diagnostics/tests/resolve/underscoreInCatchBlockWithEnabledFeature.kt @@ -1,5 +1,6 @@ // !LANGUAGE: +ForbidReferencingToUnderscoreNamedParameterOfCatchBlock // !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNUSED_ANONYMOUS_PARAMETER -UNUSED_EXPRESSION +// FULL_JDK fun foo() { try { diff --git a/compiler/testData/ir/irText/firProblems/throwableStackTrace.fir.txt b/compiler/testData/ir/irText/firProblems/throwableStackTrace.fir.txt index 9cc317ef8ad..23028c6f810 100644 --- a/compiler/testData/ir/irText/firProblems/throwableStackTrace.fir.txt +++ b/compiler/testData/ir/irText/firProblems/throwableStackTrace.fir.txt @@ -2,4 +2,7 @@ FILE fqName: fileName:/throwableStackTrace.kt FUN name:foo visibility:public modality:FINAL <> (t:kotlin.Throwable) returnType:kotlin.Unit VALUE_PARAMETER name:t index:0 type:kotlin.Throwable BLOCK_BODY - ERROR_CALL 'Unresolved reference: R|kotlin/stackTrace|' type=IrErrorType + CALL 'public open fun setStackTrace (p0: kotlin.Array?): kotlin.Unit declared in java.lang.Throwable' type=kotlin.Unit origin=EQ + $this: GET_VAR 't: kotlin.Throwable declared in .foo' type=kotlin.Throwable origin=null + p0: CALL 'public open fun getStackTrace (): kotlin.Array? declared in java.lang.Throwable' type=kotlin.Array? origin=GET_PROPERTY + $this: GET_VAR 't: kotlin.Throwable declared in .foo' type=kotlin.Throwable origin=null