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 0c6ad16c76b..74e235a5f0d 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 @@ -549,10 +549,7 @@ internal fun JavaAnnotation.toFirAnnotationCall( else -> buildArgumentMapping(session, javaTypeParameterStack, lookupTag!!, arguments) } ?: buildArgumentList { this@toFirAnnotationCall.arguments.mapTo(arguments) { - val expectedArgumentType = buildErrorTypeRef { - diagnostic = ConeSimpleDiagnostic("java annotation argument without expected type") - } - it.toFirExpression(session, javaTypeParameterStack, expectedArgumentType) + it.toFirExpression(session, javaTypeParameterStack, null) } } calleeReference = FirReferencePlaceholderForResolvedAnnotations @@ -623,15 +620,17 @@ private fun JavaType?.toConeProjectionWithoutEnhancement( } internal fun JavaAnnotationArgument.toFirExpression( - session: FirSession, javaTypeParameterStack: JavaTypeParameterStack, expectedTypeRef: FirTypeRef + session: FirSession, javaTypeParameterStack: JavaTypeParameterStack, expectedTypeRef: FirTypeRef? ): FirExpression { return when (this) { is JavaLiteralAnnotationArgument -> value.createConstantOrError(session) is JavaArrayAnnotationArgument -> buildArrayOfCall { - typeRef = expectedTypeRef - val argumentTypeRef = buildResolvedTypeRef { - type = expectedTypeRef.coneTypeSafe()?.lowerBoundIfFlexible()?.arrayElementType() - ?: ConeClassErrorType(ConeSimpleDiagnostic("expected type is not array type")) + val argumentTypeRef = expectedTypeRef?.let { + typeRef = it + buildResolvedTypeRef { + type = it.coneTypeSafe()?.lowerBoundIfFlexible()?.arrayElementType() + ?: ConeClassErrorType(ConeSimpleDiagnostic("expected type is not array type")) + } } argumentList = buildArgumentList { getElements().mapTo(arguments) { it.toFirExpression(session, javaTypeParameterStack, argumentTypeRef) }