I would like to change signatures of some function...
# compiler
g
I would like to change signatures of some functions and run some checks (that some things are used correctly). If I am not mistaken, it means that I have to write FIR extension(s). What extension classes should I extend? For now, I know only
FirDeclarationGenerationExtension
(that cannot change existing functions nor run diagnostics as far as I know).
1
b
The only change to an element we allow in FIR is status (modifiers, essentially) via
FirStatusTransformerExtension
. If you need to change the signature in FIR, the best you can achieve is make the original function private and generate another function which should be used instead. But that doesn't change the calling code, so it really depends on your specific use-case. For checks you'll need
FirAdditionalCheckersExtension
. Completely changing the signature is supported in IR though. You'll just need to make sure every
IrCall
to the function is updated as well.
g
Got it. I'll try this workaround. Here is the use-case. I just want to add several new arguments to functions which can accept values user pass. Specifically, I would like to change a function like
Copy code
fun <S, @Supplied T, @Supplied U, V> myCoolFunction(arg1: Type1, arg2: Type2): ReturnType
to make it look like
Copy code
fun <S, @Supplied T, @Supplied U, V> myCoolFunction(arg1: Type1, arg2: Type2, suppliedTypeForT: SuppliedType<T>, suppliedTypeForU: SuppliedType<U>): ReturnType
Anyway, thank you very much!