@@ -775,35 +775,38 @@ provide default values for optional parameters:
775
775
class C {
776
776
void m1([int i]);
777
777
void m2({String name});
778
+ void m3({String otherName = "Smith"}); // OK, too.
778
779
}
779
780
780
781
augment class C {
781
782
augment m1([i = 1]) {}
782
- augment m2({name = "Smith"}) {}
783
+ augment m2({name = "John"}) {}
784
+ augment m3({otherName}) {}
783
785
}
784
786
```
785
787
786
788
An optional formal parameter has the default value _ d_ if exactly one
787
789
declaration of that formal parameter in the augmentation chain specifies a
788
790
default value, and it is _ d_ . An optional formal parameter does not have an
789
791
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.
792
+ augmentation chain specifies a default value; in this case, the default value
793
+ is introduced implicitly with the value null in the case where the parameter
794
+ has a nullable declared type, and no default values for that parameter are
795
+ specified in the augmentation chain.
793
796
794
797
It's a ** compile-time** error if:
795
798
796
799
* The signature of the augmenting function does not [ match] [ signature
797
800
matching] the signature of the augmented function.
798
801
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.*
802
+ * The augmentation chain has two or more specifications of a default value
803
+ for the same optional parameter. This is an error even in the case where
804
+ all of them are identical. * Default values are defined by the introductory
805
+ function or an augmentation, but at most once.*
803
806
804
807
* 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. *
808
+ optional parameter whose declared type is potentially non-nullable, and
809
+ the declared function is not abstract.
807
810
808
811
* A function is not complete after all augmentations are applied, unless it's
809
812
an instance member and the surrounding class is abstract. * Every function
@@ -884,11 +887,17 @@ It's a **compile-time error** if:
884
887
* The signature of the augmenting function does not [ match] [ signature
885
888
matching] the signature of the augmented function.
886
889
887
- * The augmenting constructor parameters specify any default values, and
888
- the constructor is not a non-redirecting factory. * Default values are
889
- defined by the introductory constructor, except when this precludes the
890
- augmentation from choosing whether or not the constructor should be
891
- redirecting.*
890
+ * The augmentation chain has two or more specifications of a default value
891
+ for the same optional parameter. This is an error even in the case where
892
+ all of them are identical. * Default values are defined by the introductory
893
+ declaration or an augmentation, but at most once.*
894
+
895
+ * The augmentation chain has exactly one specification of a default value
896
+ for an optional parameter, and the constructor is a redirecting factory.
897
+
898
+ * The augmentation chain has no specifications of a default value for an
899
+ optional parameter whose declared type is potentially non-nullable, and
900
+ the constructor is not a redirecting factory.
892
901
893
902
* The introductory constructor is ` const ` and the augmenting constructor
894
903
is not or vice versa. * An augmentation can't change whether or not a
0 commit comments