mzgreen
01/29/2023, 10:32 AMfun foo(@Boo x: String) {
println(x)
}
foo() // should print "Boo!"
Basically I want to add the default value for an annotated parameter. I was able to replace the existing default param like:
fun foo(@Boo x: String = "") {
println(x)
}
foo() // prints "Boo!"
I got this working. Now I’m trying to get rid of that explicit default param. If I remove it then I get an error about missing argument when I call foo()
. I looked at Compose compiler and learned about DiagnosticSuppressor
, I hacked a quick implementation and now I’m able to get rid of that error. But the default param is not there at all, the compiler crashes before it even executes my code that replaces the default value. I’m using IrElementTransformerVoidWithContext
and overriding visitCall
but like I said - it seems that it’s executed too late. I need to be able to hook into the compiler at earlier stage and provide my own default value for the parameter. I’ve tried overriding other methods in IrElementTransformerVoidWithContext
as well but none of them is invoked before the compiler crash.
What am I missing here? What is the name of the thing I should use? Or maybe IrElementTransformerVoidWithContext
+ visitCall
is not the best choice for this in general and I should do it in a different way?