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)
ansman
04/05/2024, 7:35 PM
So is there a way to "copy" or otherwise resolve the expression
ansman
04/05/2024, 7:38 PM
I suppose I could transform the expression but there are a lot of them
d
damian
04/05/2024, 8:36 PM
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
ansman
04/05/2024, 8:37 PM
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.