Index: pkg/analyzer/lib/src/generated/parser.dart |
diff --git a/pkg/analyzer/lib/src/generated/parser.dart b/pkg/analyzer/lib/src/generated/parser.dart |
index 3084970abd65999132f168ad7129cc78526a5fba..d4001e839c5f58602668194d206d0a0895aaf69c 100644 |
--- a/pkg/analyzer/lib/src/generated/parser.dart |
+++ b/pkg/analyzer/lib/src/generated/parser.dart |
@@ -4413,6 +4413,9 @@ class Parser { |
initializers.add(_parseConstructorFieldInitializer()); |
} |
} while (_optional(TokenType.COMMA)); |
+ if (factoryKeyword != null) { |
+ _reportErrorForToken(ParserErrorCode.FACTORY_WITH_INITIALIZERS, factoryKeyword, []); |
+ } |
} |
ConstructorName redirectedConstructor = null; |
FunctionBody body; |
@@ -7944,6 +7947,13 @@ class ParserErrorCode extends ErrorCode { |
static const ParserErrorCode FACTORY_TOP_LEVEL_DECLARATION = const ParserErrorCode('FACTORY_TOP_LEVEL_DECLARATION', "Top-level declarations cannot be declared to be 'factory'"); |
+ static const ParserErrorCode FACTORY_WITH_INITIALIZERS |
+ = const ParserErrorCode( |
+ 'FACTORY_WITH_INITIALIZERS', |
+ "A 'factory' constructor cannot have initializers", |
+ "Either remove the 'factory' keyword to make this a generative " |
+ "constructor or remove the initializers."); |
+ |
static const ParserErrorCode FACTORY_WITHOUT_BODY = const ParserErrorCode('FACTORY_WITHOUT_BODY', "A non-redirecting 'factory' constructor must have a body"); |
static const ParserErrorCode FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR = const ParserErrorCode('FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR', "Field initializers can only be used in a constructor"); |