-
Notifications
You must be signed in to change notification settings - Fork 228
Description
In the specification of primary constructors there is text that reads:
The grammar is ambiguous with regard to the keyword
factory. For example,factory() => C();could be a method namedfactorywith an implicitly inferred return type, or it could be a factory constructor whose name is the name of the enclosing class.This ambiguity is resolved as follows: When a Dart parser expects to parse a
<memberDeclaration>, and the beginning of the declaration isfactoryor one or more of the modifiersconst,augment, orexternalfollowed byfactory, it proceeds to parse the following input as a factory constructor.
It's my understanding that an instance method can't start with const, so I believe that the presence of a const modifier would already force the construct to be interpreted as a constructor (once the parser determines that it isn't a field). If that's true, then it would be better to remove the unnecessary const from the list to avoid confusion.
I don't know whether the augmentations feature is going to allow both augment and external to be applied to the same constructor declaration, but if const is removed from the list then the "or more" might not be needed.