Description
The macro apis today do not give access to default values for parameters (or initializer expressions for variables either).
When augmenting a function today you are not allowed to specify default values, so we probably don't need them in that case. However, when overriding a method with a new declaration in a class (so you aren't augmenting an existing method/constructor, you are specifying a new one, which is an override), you do likely need access to the default values of the original parameters.
We could likely only provide these as Code
objects and not values (the values might be user types, have unresolved identifiers, etc). But that should be sufficient as the use case is really just plopping in the same default value.
Concerns
I am concerned that in the case of unresolved identifiers (that will be produced in phase 2), we can't even always produce a valid augmentation library (at least in phase 1, although it would be challenging even in phase 2).
Consider a macro that runs in phase one, but it creates a type that extends some other type and overrides some members. Generally that would be hard to actually do since you can't introspect over members, but the macro could actually live on a member, something like this:
class A {
@SomeMacro()
void foo([int x = y]); // y is generated in phase 2!
}
// Generated in phase one, how do we refer to y properly if we don't know where it comes from?
class B extends A {
void foo([int x = y])
}
Possibly we could just assume that any unresolved identifier will eventually exist in the current library, and not do any prefix. But that seems sketchy.
Other options
Alternatively, could we add a way of referring to the overridden default value? This would be generally useful, and would avoid the issue entirely. Maybe something like void foo({super.x})
or void foo({int x = super.default})
?