Index: pkg/front_end/lib/src/fasta/parser/parser.dart |
diff --git a/pkg/front_end/lib/src/fasta/parser/parser.dart b/pkg/front_end/lib/src/fasta/parser/parser.dart |
index 2a58ae6dbfcc3a8c525a84b269a5f7552ef7dc96..dc89c469d2a55a9c2ec09f5dc33f383c37bceba7 100644 |
--- a/pkg/front_end/lib/src/fasta/parser/parser.dart |
+++ b/pkg/front_end/lib/src/fasta/parser/parser.dart |
@@ -1820,24 +1820,26 @@ class Parser { |
Token parseFactoryMethod(Token token) { |
assert(isFactoryDeclaration(token)); |
Token start = token; |
- Token externalModifier; |
- if (identical(token.stringValue, 'external')) { |
- externalModifier = token; |
- token = token.next; |
- } |
- if (optional('const', token)) { |
- token = token.next; // Skip const. |
+ bool isExternal = false; |
+ int modifierCount = 0; |
+ while (isModifier(token)) { |
+ if (optional('external', token)) { |
+ isExternal = true; |
+ } |
+ token = parseModifier(token); |
+ modifierCount++; |
} |
+ listener.handleModifiers(modifierCount); |
Token factoryKeyword = token; |
listener.beginFactoryMethod(factoryKeyword); |
- token = token.next; // Skip 'factory'. |
+ token = expect('factory', token); |
token = parseConstructorReference(token); |
token = parseFormalParameters(token); |
token = parseAsyncModifier(token); |
if (optional('=', token)) { |
token = parseRedirectingFactoryBody(token); |
} else { |
- token = parseFunctionBody(token, false, externalModifier != null); |
+ token = parseFunctionBody(token, false, isExternal); |
} |
listener.endFactoryMethod(start, token); |
return token.next; |