[FIR] Make ClassId not null in enum call mapped from java

This commit is contained in:
Kirill Rakhman
2023-10-23 16:35:42 +02:00
committed by Space Team
parent c9e328528e
commit 56f53fbd0b
@@ -131,7 +131,7 @@ internal fun JavaAnnotationArgument.toFirExpression(
// a static import. In this case, the parameter default initializer will not have its type set, which isn't usually an // a static import. In this case, the parameter default initializer will not have its type set, which isn't usually an
// issue except in edge cases like KT-47702 where we do need to evaluate the default values of annotations. // issue except in edge cases like KT-47702 where we do need to evaluate the default values of annotations.
// As a fallback, we use the expected type which should be the type of the enum. // As a fallback, we use the expected type which should be the type of the enum.
classId = enumClassId ?: expectedTypeRef?.coneTypeOrNull?.lowerBoundIfFlexible()?.classId, classId = requireNotNull(enumClassId ?: expectedTypeRef?.coneTypeOrNull?.lowerBoundIfFlexible()?.classId),
entryName = entryName entryName = entryName
) )
is JavaClassObjectAnnotationArgument -> buildGetClassCall { is JavaClassObjectAnnotationArgument -> buildGetClassCall {
@@ -172,9 +172,9 @@ private val JAVA_TARGETS_TO_KOTLIN = mapOf(
"TYPE_USE" to EnumSet.of(AnnotationTarget.TYPE) "TYPE_USE" to EnumSet.of(AnnotationTarget.TYPE)
) )
private fun buildEnumCall(session: FirSession, classId: ClassId?, entryName: Name?): FirPropertyAccessExpression { private fun buildEnumCall(session: FirSession, classId: ClassId, entryName: Name?): FirPropertyAccessExpression {
return buildPropertyAccessExpression { return buildPropertyAccessExpression {
val resolvedCalleeReference: FirResolvedNamedReference? = if (classId != null && entryName != null) { val resolvedCalleeReference: FirResolvedNamedReference? = if (entryName != null) {
session.symbolProvider.getClassDeclaredPropertySymbols(classId, entryName) session.symbolProvider.getClassDeclaredPropertySymbols(classId, entryName)
.firstOrNull()?.let { propertySymbol -> .firstOrNull()?.let { propertySymbol ->
buildResolvedNamedReference { buildResolvedNamedReference {
@@ -198,13 +198,11 @@ private fun buildEnumCall(session: FirSession, classId: ClassId?, entryName: Nam
diagnostic = ConeSimpleDiagnostic("Enum entry name is null in Java for $classId", DiagnosticKind.Java) diagnostic = ConeSimpleDiagnostic("Enum entry name is null in Java for $classId", DiagnosticKind.Java)
} }
if (classId != null) { this.coneTypeOrNull = ConeClassLikeTypeImpl(
this.coneTypeOrNull = ConeClassLikeTypeImpl( classId.toLookupTag(),
classId.toLookupTag(), emptyArray(),
emptyArray(), isNullable = false
isNullable = false )
)
}
} }
} }