👋
I'm currently porting my K1 compiler plugin to K2.
I want to add a new function to a class. I replaced the
SyntheticResolveExtension
with a
FirDeclarationGenerationExtension
to add the signature. The Fir phase runs without exception, however the method is missing during Ir phase.
override fun generateFunctions(
callableId: CallableId,
context: MemberGenerationContext?
): List<FirNamedFunctionSymbol> {
val newFunction = buildSimpleFunction {
moduleData = session.moduleData
name = callableId.callableName
dispatchReceiverType = context?.owner?.defaultType()
symbol = FirNamedFunctionSymbol(callableId)
origin = context!!.owner.origin // TODO
status = FirResolvedDeclarationStatusImpl(Visibilities.Public, Modality.OPEN, EffectiveVisibility.Public)
returnTypeRef = buildResolvedTypeRef { type = session.builtinTypes.unitType.type }
}
return listOf(newFunction.symbol)
}
During class lowering I want to add the function body. However the method is missing in
irClass.functions
. Any ideas why?