I want to reuse a default value expression from on...
# compiler
a
I want to reuse a default value expression from one value parameter for another one. Just using
.defaultValue
directly doesn't work in all cases because the new default value needs to be "resolved" (for example, if the expression is a
FirStringConcatenationCall
then its
argumentList
must be a
FirResolvedArgumentList
which the original expression doesn't have)
So is there a way to "copy" or otherwise resolve the expression
I suppose I could transform the expression but there are a lot of them
d
Don't have an answer for you, but am curious about this. Is that maybe because default values can refer to other (earlier) parameters? e.g.
fun foo(x: Int = 0, y: Int = x + 1, z: Int = y + 1)
a
I think it’s because during this phase, they might not all be resolved. @Javier had a great idea of just adding a stub and then generating it in the backend instead.