Javier
11/19/2025, 12:23 PMbuildArrayliteral {} to populate an array of an annotation
I am trying to build this:
@Database(
entities = [
OneEntity::class,
TwoEntity:class,
]
)
abstract class FooDatabase : RoomDatabase()
Everything is created, but building the arrow with the function above fails due `Expected expression FirArrayLiteralImpl to be resolved`. But I do not find a way to resolve this expression.dmitriy.novozhilov
11/19/2025, 12:24 PMFirArrayLiteralImpl properties
• create the same in your pluginJavier
11/19/2025, 12:36 PMconeType, thought it was inferred by the list of arguments
Additionally, to create that array of kclass, I am using buildClassReferenceExpression so:
val entitiesClassReferences: List<FirClassReferenceExpression> =
entities
.map {
buildClassReferenceExpression {
coneTypeOrNull = it.defaultType()
classTypeRef = buildResolvedTypeRef { coneType = it.defaultType() }
}
}
.toList()
But it is failing with
Should not be here: class org.jetbrains.kotlin.fir.expressions.impl.FirClassReferenceExpressionImpl <getClass>(R|com/qonto/dev/app/common/one/Param1|)
java.lang.IllegalStateException: Should not be here: class org.jetbrains.kotlin.fir.expressions.impl.FirClassReferenceExpressionImpl <getClass>(R|com/qonto/dev/app/common/one/Param1|)
at org.jetbrains.kotlin.fir.backend.Fir2IrVisitor.visitElement(Fir2IrVisitor.kt:103)
Is it a valid approach or should I use a different thing?dmitriy.novozhilov
11/19/2025, 12:40 PMconeTypeOrNull should be KClass<out YourClass>, not YourClass though.
In general, the approach from my previous message valid in this case too.Javier
11/19/2025, 12:44 PM*, I need to change it from KClass<*> to KClass<Out *> ?dmitriy.novozhilov
11/19/2025, 12:45 PMKClass<*> is fine.Javier
11/19/2025, 1:06 PMFirGetClassCallImpl instead of FirClassReferenceExpressionImpl, is there an easy way to convert to the FirGetClassCall?dmitriy.novozhilov
11/19/2025, 1:09 PMFirClassReferenceExpression is used for annotation arguments on declarations deserialized from dependencies.
For source you indeed need to use FirGetClassCall.
There is no conversion between them as they never appear together.Javier
11/19/2025, 1:19 PMcreate* like functions? My premise is avoiding using build* function as they are for internal things, but adding/replacing annotation means using multiple build* functionsdmitriy.novozhilov
11/19/2025, 1:57 PM