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

Unified Diff: lib/compiler/implementation/elements/elements.dart

Issue 10832291: Add missing abort on duplicate class fields. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Added TODOs at duplicate cancels. Created 8 years, 4 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 | tests/co19/co19-leg.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/elements/elements.dart
diff --git a/lib/compiler/implementation/elements/elements.dart b/lib/compiler/implementation/elements/elements.dart
index ea7c5dde6e0b27d0dad267e3288cfe1791fa80f5..03895b2087442c5c6508b957b756e0c79043ea58 100644
--- a/lib/compiler/implementation/elements/elements.dart
+++ b/lib/compiler/implementation/elements/elements.dart
@@ -287,6 +287,7 @@ class ContainerElement extends Element {
Element existing,
DiagnosticListener listener) {
void reportError(Element other) {
+ // TODO(ahe): Do something similar to Resolver.reportErrorWithContext.
listener.cancel('duplicate definition of ${element.name.slowToString()}',
element: element);
listener.cancel('existing definition', element: other);
@@ -404,6 +405,7 @@ class LibraryElement extends CompilationUnitElement {
} else {
Element existing = elements.putIfAbsent(element.name, () => element);
if (existing !== element) {
+ // TODO(ahe): Do something similar to Resolver.reportErrorWithContext.
listener.cancel('duplicate definition', token: element.position());
listener.cancel('existing definition', token: existing.position());
}
@@ -1030,7 +1032,12 @@ class ClassElement extends ContainerElement
|| element.kind == ElementKind.SETTER) {
addGetterOrSetter(element, localMembers[element.name], listener);
} else {
- localMembers[element.name] = element;
+ Element existing = localMembers.putIfAbsent(element.name, () => element);
+ if (existing !== element) {
+ // TODO(ahe): Do something similar to Resolver.reportErrorWithContext.
+ listener.cancel('duplicate definition', token: element.position());
+ listener.cancel('existing definition', token: existing.position());
+ }
}
}
« no previous file with comments | « no previous file | tests/co19/co19-leg.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698