Skip to content

Commit

Permalink
move const method error reporting into parser
Browse files Browse the repository at this point in the history
Change-Id: Ibae4aeb0362138e742f80186ed98a20eb3469ba1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/116661
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
  • Loading branch information
danrubel authored and commit-bot@chromium.org committed Sep 11, 2019
1 parent 9113fb3 commit 16c7ac9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
6 changes: 0 additions & 6 deletions pkg/analyzer/lib/src/fasta/ast_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import 'package:front_end/src/fasta/messages.dart'
Message,
MessageCode,
messageConstConstructorWithBody,
messageConstMethod,
messageConstructorWithReturnType,
messageConstructorWithTypeParameters,
messageDirectiveAfterDeclaration,
Expand Down Expand Up @@ -1607,11 +1606,6 @@ class AstBuilder extends StackListener {
throw new UnimplementedError();
}

if (modifiers?.constKeyword != null) {
// This error is also reported in OutlineBuilder.endMethod
handleRecoverableError(
messageConstMethod, modifiers.constKeyword, modifiers.constKeyword);
}
checkFieldFormalParameters(parameters);
currentDeclarationMembers.add(ast.methodDeclaration(
comment,
Expand Down
4 changes: 4 additions & 0 deletions pkg/front_end/lib/src/fasta/parser/parser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3428,6 +3428,10 @@ class Parser {
//
// method
//
if (varFinalOrConst != null) {
assert(optional('const', varFinalOrConst));
reportRecoverableError(varFinalOrConst, fasta.messageConstMethod);
}
switch (kind) {
case DeclarationKind.Class:
// TODO(danrubel): Remove beginInitializers token from method events
Expand Down
4 changes: 2 additions & 2 deletions pkg/front_end/lib/src/fasta/source/outline_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import '../fasta_codes.dart'
Message,
messageConstConstructorWithBody,
messageConstInstanceField,
messageConstMethod,
messageConstructorWithReturnType,
messageConstructorWithTypeParameters,
messageExpectedBlockToSkip,
Expand Down Expand Up @@ -1031,7 +1030,8 @@ class OutlineBuilder extends StackListener {
beginInitializers: beginInitializers);
} else {
if (isConst) {
addProblem(messageConstMethod, varFinalOrConstOffset, 5);
// TODO(danrubel): consider removing this
// because it is an error to have a const method.
modifiers &= ~constMask;
}
final int startCharOffset =
Expand Down

0 comments on commit 16c7ac9

Please sign in to comment.