@@ -616,10 +616,10 @@ modifier `required` as well as a default value.
616616
617617### Static processing
618618
619- The ability to use ` new ` rather than the class name in declarations of
620- ordinary (non-declaring ) constructors is purely syntactic. The static
621- analysis and meaning of such constructors is identical to the form that
622- uses the class name.
619+ The ability to use ` new ` or ` factory ` as a keyword and omitting the class
620+ name in declarations of ordinary (non-primary ) constructors is purely
621+ syntactic. The static analysis and meaning of such constructors is
622+ identical to the form that uses the class name.
623623
624624The name of a primary constructor of the form
625625` 'const'? id1 <typeParameters>? <declaringParameterList> ` is ` id1 ` * (that
@@ -646,8 +646,8 @@ generative constructor, unless _D_ is an extension type.
646646* For a class, mixin class, or enum declaration, this ensures that every
647647generative constructor invocation will invoke the primary constructor,
648648either directly or via a series of generative redirecting constructors.
649- This is required in order to allow initializers with no access to ` this ` to
650- use the parameters.*
649+ This is required in order to allow non-late instance variable initializers
650+ to access the parameters.*
651651
652652If _ D_ is an extension type, it is a compile-time error if the primary
653653constructor that _ D_ contains does not have exactly one parameter.
@@ -752,12 +752,6 @@ A compile-time error occurs if _p_ contains a term of the form `this.v`, or
752752reason for this error is that the modifier ` covariant ` must be specified on
753753the declaration of ` v ` which is known to exist, not on the parameter.*
754754
755- A compile-time error occurs if _ p_ has both of the modifiers ` covariant `
756- and ` final ` , also if the latter is implicitly induced * (which can occur in a
757- primary constructor of an extension type declaration)* . * A final instance
758- variable cannot be covariant, because being covariant is a property of the
759- setter.*
760-
761755A compile-time error occurs if _ p_ has the modifier ` covariant ` , but
762756not ` var ` . * This parameter does not induce a setter.*
763757
@@ -813,8 +807,7 @@ fact that the primary constructor is actually placed outside the braces
813807that delimit the class body.*
814808
815809Next, _ k2_ has the modifier ` const ` iff the keyword ` const ` occurs just
816- before the name of _ D_ or before ` this ` , or if _ D_ is an ` enum `
817- declaration.
810+ before the name of _ D_ , or _ D_ is an ` enum ` declaration.
818811
819812Consider the case where _ k_ is a primary constructor. If the name ` C ` in
820813_ D_ and the type parameter list, if any, is followed by ` .id ` where ` id ` is
@@ -846,8 +839,9 @@ positional or named parameter remains optional; if it has a default value
846839 in _ L2_ by ` this.p ` , along with its default value, if any. Next, a
847840 semantic instance variable declaration corresponding to the syntax ` T p; `
848841 or ` final T p; ` is added to _ D2_ . It includes the modifier ` final ` if the
849- parameter in _ L_ has the modifier ` final ` , or _ D_ is an ` extension type `
850- declaration and _ k_ is a declaring header constructor. In all cases, if
842+ parameter in _ L_ has the modifier ` final ` and _ D_ is not an `extension
843+ type` decaration; if _D_ is an ` extension type` declaration then the name
844+ of ` p ` specifies the name of the representation variable. In all cases, if
851845 ` p ` has the modifier ` covariant ` then this modifier is removed from the
852846 parameter in _ L2_ , and it is added to the instance variable declaration
853847 named ` p ` .
@@ -863,8 +857,9 @@ This feature is language versioned.
863857
864858* It introduces a breaking change in the grammar, which implies that
865859developers must explicitly enable it. In particular, ` factory() {} ` in a
866- class body used to be a method declaration. With this feature it will be
867- a factory constructor declaration.*
860+ class body used to be a method declaration whose name is ` factory ` . With
861+ this feature, it is a factory constructor declaration whose name is the
862+ name of the enclosing class, enum, or extension type declaration.*
868863
869864### Discussion
870865
@@ -881,7 +876,7 @@ variables, and that allows us to move code from an initializer list to a
881876variable initializer and vice versa without worrying about changing the
882877meaning of the code. This in turn makes it easier to change a regular
883878(non-primary) constructor to a primary constructor, or vice versa. So we
884- assume that the unusual scoping structure will make sense in practice.
879+ expect the unusual scoping structure to work reasonably well in practice.
885880
886881The proposal allows an ` enum ` declaration to include the modifier ` const `
887882just before the name of the declaration when it has a primary constructor,
0 commit comments