scala3
scala3 copied to clipboard
Lift all non trivial prefixes for default parameters
Checking if the prefix is pure is not enough to know if we need to list the prefix. In the case of default parameters, the prefix tree might be used several times to compute the default values. This expression should only be computed once and therefore it should be lifted if there is some computation/allocation involved. Furthermore, if the prefix contains a local definition, it must be lifted to avoid duplicating the definition.
A similar situation could happen with dependent default parameters. This currently works as expected.
Fixes #15315