Open Cat-sushi opened 1 year ago
That would require type checking to compare values. Those would presumably be constant values only, but I'm sure it will give new and exciting challenges.
Is a function type with no default value a supertype of a function type with a default value? Or subtype? Or can it even exist.
void Function([int x]) f = ([int x = 0]) {}; // Allowed or not?
I pretty sure the inconvenience and complexity is not worth the gain.
void Function([int x]) f = ([int x = 0]) {}; //
If that doesn't work anymore, that'd be a significant breaking change.
Freezed relies on a sentinel default value for supporting copyWith(a: null):
Obj copyWith({MyClass x}) => ({Object x = _sentinel} ) {...}
Removal or change of default values is almost always breaking. The solo exception is removal of default
null
from nullable parameters. So, I think default values of parameters should be parts of function types, to be checked by the compiler.cf. #3206