File tree Expand file tree Collapse file tree 1 file changed +43
-0
lines changed
Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change @@ -25335,6 +25335,49 @@ WarningCode:
2533525335 problemMessage: Methods named 'factory' will become constructors when the primary_constructors feature is enabled.
2533625336 correctionMessage: Try adding a return type or modifier before the method's name, or change the name of the method.
2533725337 hasPublishedDocs: false
25338+ documentation: |-
25339+ #### Description
25340+
25341+ The analyzer produces this diagnostic when the declaration of an instance
25342+ method named `factory` is interpreted as a constructor declaration after
25343+ the `primary_constructors` feature is enabled.
25344+
25345+ This issue only affects declarations that lack a return type and where the
25346+ method name is the first token or is preceded only by `external`,
25347+ `augment`, or `augment external`. The `augment` and `augment external`
25348+ keywords are valid only after the augmentations feature is enabled.
25349+
25350+ #### Example
25351+
25352+ The following code produces this diagnostic because the instance method
25353+ named `factory` has no return type or modifiers:
25354+
25355+ ```dart
25356+ // @dart=3.10
25357+ class C {
25358+ [!factory!]() => C();
25359+ }
25360+ ```
25361+
25362+ #### Common fixes
25363+
25364+ If the name can be changed, then rename the method:
25365+
25366+ ```dart
25367+ // @dart=3.10
25368+ class C {
25369+ make() => C();
25370+ }
25371+ ```
25372+
25373+ If the name must remain `factory`, then add a return type:
25374+
25375+ ```dart
25376+ // @dart=3.10
25377+ class C {
25378+ C factory() => C();
25379+ }
25380+ ```
2533825381 deprecatedImplement:
2533925382 type: staticWarning
2534025383 parameters:
You can’t perform that action at this time.
0 commit comments