diff --git a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/JavaUtils.kt b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/JavaUtils.kt index ae08861ad9f..a5cd2182cf5 100644 --- a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/JavaUtils.kt +++ b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/JavaUtils.kt @@ -776,13 +776,22 @@ private fun FirConstExpression<*>.setProperType(session: FirSession): FirConstEx private fun JavaType.toFirResolvedTypeRef( session: FirSession, javaTypeParameterStack: JavaTypeParameterStack ): FirResolvedTypeRef { - if (this is JavaClassifierType) return toFirResolvedTypeRef( - session, - javaTypeParameterStack, - isForSupertypes = false, - forTypeParameterBounds = false - ) - return buildResolvedTypeRef { - type = ConeClassErrorType(ConeSimpleDiagnostic("Unexpected JavaType: $this", DiagnosticKind.Java)) + return when (this) { + is JavaClassifierType -> toFirResolvedTypeRef( + session, + javaTypeParameterStack, + isForSupertypes = false, + forTypeParameterBounds = false + ) + is JavaPrimitiveType -> buildResolvedTypeRef { + type = toConeKotlinTypeWithoutEnhancement( + session, + javaTypeParameterStack, + ) + this@toFirResolvedTypeRef.annotations.mapTo(annotations) { it.toFirAnnotationCall(session, javaTypeParameterStack) } + } + else -> buildResolvedTypeRef { + type = ConeClassErrorType(ConeSimpleDiagnostic("Unexpected JavaType: ${this@toFirResolvedTypeRef}", DiagnosticKind.Java)) + } } } diff --git a/compiler/testData/loadJava/compiledJava/annotations/ClassObjectArrayInParam.fir.txt b/compiler/testData/loadJava/compiledJava/annotations/ClassObjectArrayInParam.fir.txt index ac16c143e73..a8f23ba89dc 100644 --- a/compiler/testData/loadJava/compiledJava/annotations/ClassObjectArrayInParam.fir.txt +++ b/compiler/testData/loadJava/compiledJava/annotations/ClassObjectArrayInParam.fir.txt @@ -5,7 +5,7 @@ public open class ClassObjectArrayInParam : R|kotlin/Any| { public constructor(vararg value: R|kotlin/Array>|): R|test/ClassObjectArrayInParam.Anno| } - @R|test/ClassObjectArrayInParam.Anno|((((R|ft|)), ((R|ft|)), ((R|ft|)), ((R|ft, kotlin/collections/List<*>?>|)), ((R|ERROR CLASS: Unexpected JavaType: org.jetbrains.kotlin.fir.types.builder.FirResolvedTypeRefBuilder@4abd3f24|)), ((R|ERROR CLASS: Unexpected JavaType: org.jetbrains.kotlin.fir.types.builder.FirResolvedTypeRefBuilder@6214f104|)), ((R|ERROR CLASS: Unexpected JavaType: org.jetbrains.kotlin.fir.types.builder.FirResolvedTypeRefBuilder@5450f4f|)))) public open class Nested : R|kotlin/Any| { + @R|test/ClassObjectArrayInParam.Anno|((((R|ft|)), ((R|ft|)), ((R|ft|)), ((R|ft, kotlin/collections/List<*>?>|)), ((R|ERROR CLASS: Unexpected JavaType: JavaArrayTypeImpl: PsiType:String[][]|)), ((R|ERROR CLASS: Unexpected JavaType: JavaArrayTypeImpl: PsiType:int[][]|)), ((R|kotlin/Unit|)))) public open class Nested : R|kotlin/Any| { public constructor(): R|test/ClassObjectArrayInParam.Nested| }