Ng Hui Qin
02/08/2024, 6:18 PMfun simpleFunction(): Int = TODO()
How could I build expression to present : Int = TODO()
in FirFunction?
Try using example in https://github.com/JetBrains/kotlin/blob/master/docs/fir/fir-basics.md, I guess the direction is like
val myFunction = buildSimpleFunction {
name = Name.identifier("simpleFunction")
... << starting here I lose my direction in building return type, equal token and TODO() expression
}
Ng Hui Qin
02/08/2024, 6:19 PMdmitriy.novozhilov
02/12/2024, 8:51 AMIrGenerationExtension
But if you really want to generate this call at frontend, you can just write TODO()
call in the source code, inspect it's content in the debugger (e.g. by implementing some empty function call checker, which will be called on this call) and accordingly initialize all required fields in buildFunctionCall
As for buildSimpleFunction
, I don't recommend use it
There is a bunch of different utilities for creation of declaration from plugins (named create...
), and it's better to use them
Check this file as an entrypoint
And here is an usage example