@@ -450,7 +450,7 @@ scope. *We could say that it attaches itself to the existing name.*
450
450
451
451
Augmentations aren't allowed to * replace* code, so they mostly add entirely new
452
452
declarations to the surrounding type. However, function and constructor
453
- augmentations can fill in a body for an augmented declaration that is lacks one.
453
+ augmentations can fill in a body for an augmented declaration that lacks one.
454
454
455
455
More precisely, a function or constructor declaration (introductory or
456
456
augmenting) is * incomplete* if all of:
@@ -768,14 +768,42 @@ augment class Person {
768
768
}
769
769
```
770
770
771
+ A top-level function, static method, or instance method may be augmented to
772
+ provide default values for optional parameters:
773
+
774
+ ``` dart
775
+ class C {
776
+ void m1([int i]);
777
+ void m2({String name});
778
+ }
779
+
780
+ augment class C {
781
+ augment m1([i = 1]) {}
782
+ augment m2({name = "Smith"}) {}
783
+ }
784
+ ```
785
+
786
+ An optional formal parameter has the default value _ d_ if exactly one
787
+ declaration of that formal parameter in the augmentation chain specifies a
788
+ default value, and it is _ d_ . An optional formal parameter does not have an
789
+ explicitly specified default value if none of its declarations in the
790
+ augmentation chain specifies a default value; the default value is introduced
791
+ implicitly with the value null in the case where the parameter has a nullable
792
+ declared type, and no default values are specified in the augmentation chain.
793
+
771
794
It's a ** compile-time** error if:
772
795
773
796
* The signature of the augmenting function does not [ match] [ signature
774
797
matching] the signature of the augmented function.
775
798
776
- * The augmenting function specifies any default values. * Default values are
777
- defined solely by the introductory function. Note that constructors are
778
- treated differently from other functions in this respect.*
799
+ * The augmentation chain has two or more specifications of a default
800
+ value, even in the case where they are all identical. * Default values are
801
+ defined by the introductory function or an augmentation, but at most
802
+ once.*
803
+
804
+ * The augmentation chain has no specifications of a default value for an
805
+ optional parameter whose declared type is potentially non-nullable. * In
806
+ this case the specification must be explicit.*
779
807
780
808
* A function is not complete after all augmentations are applied, unless it's
781
809
an instance member and the surrounding class is abstract. * Every function
0 commit comments