Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(157)

Unified Diff: compiler/java/com/google/dart/compiler/parser/DartParser.java

Issue 9086015: Report error for interface method with body, issue 971 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rollback extra change Created 8 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | compiler/java/com/google/dart/compiler/parser/ParserErrorCode.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: compiler/java/com/google/dart/compiler/parser/DartParser.java
diff --git a/compiler/java/com/google/dart/compiler/parser/DartParser.java b/compiler/java/com/google/dart/compiler/parser/DartParser.java
index 5912a1ff839f51739413bc4d6555a974a7005c6d..3a23979cf5c7435e5d160d1deefe713f86222969 100644
--- a/compiler/java/com/google/dart/compiler/parser/DartParser.java
+++ b/compiler/java/com/google/dart/compiler/parser/DartParser.java
@@ -114,7 +114,6 @@ public class DartParser extends CompletionHooksParserBase {
private boolean isParsingInterface;
private boolean isTopLevelAbstract;
private DartScanner.Position topLevelAbstractModifierPosition;
- private DartScanner.Position classLevelAbstractModifierPosition;
private boolean isParsingClass;
/**
@@ -868,7 +867,6 @@ public class DartParser extends CompletionHooksParserBase {
reportError(position(), ParserErrorCode.ABSTRACT_MEMBER_IN_INTERFACE);
}
modifiers = modifiers.makeAbstract();
- classLevelAbstractModifierPosition = position();
} else if (optionalPseudoKeyword(FACTORY_KEYWORD)) {
if (isParsingInterface) {
reportError(position(), ParserErrorCode.FACTORY_MEMBER_IN_INTERFACE);
@@ -1209,13 +1207,15 @@ public class DartParser extends CompletionHooksParserBase {
private DartNode parseMethodOrAccessor(Modifiers modifiers, DartTypeNode returnType) {
DartMethodDefinition method = done(parseMethod(modifiers, returnType));
// Abstract method can not have a body.
- if (method.getModifiers().isAbstract() && method.getFunction().getBody() != null) {
- Location location =
- new Location(classLevelAbstractModifierPosition,
- classLevelAbstractModifierPosition.getAdvancedColumns(ABSTRACT_KEYWORD.length()));
- reportError(new DartCompilationError(ctx.getSource(),
- location,
- ParserErrorCode.ABSTRACT_METHOD_WITH_BODY));
+ if (method.getFunction().getBody() != null) {
+ if (isParsingInterface) {
+ reportError(new DartCompilationError(method.getName(),
+ ParserErrorCode.INTERFACE_METHOD_WITH_BODY));
+ }
+ if (method.getModifiers().isAbstract()) {
+ reportError(new DartCompilationError(method.getName(),
+ ParserErrorCode.ABSTRACT_METHOD_WITH_BODY));
+ }
}
// If getter or setter, generate DartFieldDefinition instead.
if (method.getModifiers().isGetter() || method.getModifiers().isSetter()) {
« no previous file with comments | « no previous file | compiler/java/com/google/dart/compiler/parser/ParserErrorCode.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698