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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tests/co19/co19-leg.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #library('elements'); 5 #library('elements');
6 6
7 #import('../tree/tree.dart'); 7 #import('../tree/tree.dart');
8 #import('../scanner/scannerlib.dart'); 8 #import('../scanner/scannerlib.dart');
9 #import('../leg.dart'); // TODO(karlklose): we only need type. 9 #import('../leg.dart'); // TODO(karlklose): we only need type.
10 #import('../util/util.dart'); 10 #import('../util/util.dart');
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 class ContainerElement extends Element { 280 class ContainerElement extends Element {
281 ContainerElement(name, kind, enclosingElement) : 281 ContainerElement(name, kind, enclosingElement) :
282 super(name, kind, enclosingElement); 282 super(name, kind, enclosingElement);
283 283
284 abstract void addMember(Element element, DiagnosticListener listener); 284 abstract void addMember(Element element, DiagnosticListener listener);
285 285
286 void addGetterOrSetter(Element element, 286 void addGetterOrSetter(Element element,
287 Element existing, 287 Element existing,
288 DiagnosticListener listener) { 288 DiagnosticListener listener) {
289 void reportError(Element other) { 289 void reportError(Element other) {
290 // TODO(ahe): Do something similar to Resolver.reportErrorWithContext.
290 listener.cancel('duplicate definition of ${element.name.slowToString()}', 291 listener.cancel('duplicate definition of ${element.name.slowToString()}',
291 element: element); 292 element: element);
292 listener.cancel('existing definition', element: other); 293 listener.cancel('existing definition', element: other);
293 } 294 }
294 295
295 if (existing != null) { 296 if (existing != null) {
296 if (existing.kind !== ElementKind.ABSTRACT_FIELD) { 297 if (existing.kind !== ElementKind.ABSTRACT_FIELD) {
297 reportError(existing); 298 reportError(existing);
298 } else { 299 } else {
299 AbstractFieldElement field = existing; 300 AbstractFieldElement field = existing;
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 define(element, listener); 398 define(element, listener);
398 } 399 }
399 400
400 void define(Element element, DiagnosticListener listener) { 401 void define(Element element, DiagnosticListener listener) {
401 if (element.kind == ElementKind.GETTER 402 if (element.kind == ElementKind.GETTER
402 || element.kind == ElementKind.SETTER) { 403 || element.kind == ElementKind.SETTER) {
403 addGetterOrSetter(element, elements[element.name], listener); 404 addGetterOrSetter(element, elements[element.name], listener);
404 } else { 405 } else {
405 Element existing = elements.putIfAbsent(element.name, () => element); 406 Element existing = elements.putIfAbsent(element.name, () => element);
406 if (existing !== element) { 407 if (existing !== element) {
408 // TODO(ahe): Do something similar to Resolver.reportErrorWithContext.
407 listener.cancel('duplicate definition', token: element.position()); 409 listener.cancel('duplicate definition', token: element.position());
408 listener.cancel('existing definition', token: existing.position()); 410 listener.cancel('existing definition', token: existing.position());
409 } 411 }
410 } 412 }
411 } 413 }
412 414
413 /** Look up a top-level element in this library. The element could 415 /** Look up a top-level element in this library. The element could
414 * potentially have been imported from another library. Returns 416 * potentially have been imported from another library. Returns
415 * null if no such element exist. */ 417 * null if no such element exist. */
416 Element find(SourceString elementName) { 418 Element find(SourceString elementName) {
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after
1023 1025
1024 void addMember(Element element, DiagnosticListener listener) { 1026 void addMember(Element element, DiagnosticListener listener) {
1025 members = members.prepend(element); 1027 members = members.prepend(element);
1026 if (element.kind == ElementKind.GENERATIVE_CONSTRUCTOR || 1028 if (element.kind == ElementKind.GENERATIVE_CONSTRUCTOR ||
1027 element.modifiers.isFactory()) { 1029 element.modifiers.isFactory()) {
1028 constructors[element.name] = element; 1030 constructors[element.name] = element;
1029 } else if (element.kind == ElementKind.GETTER 1031 } else if (element.kind == ElementKind.GETTER
1030 || element.kind == ElementKind.SETTER) { 1032 || element.kind == ElementKind.SETTER) {
1031 addGetterOrSetter(element, localMembers[element.name], listener); 1033 addGetterOrSetter(element, localMembers[element.name], listener);
1032 } else { 1034 } else {
1033 localMembers[element.name] = element; 1035 Element existing = localMembers.putIfAbsent(element.name, () => element);
1036 if (existing !== element) {
1037 // TODO(ahe): Do something similar to Resolver.reportErrorWithContext.
1038 listener.cancel('duplicate definition', token: element.position());
1039 listener.cancel('existing definition', token: existing.position());
1040 }
1034 } 1041 }
1035 } 1042 }
1036 1043
1037 InterfaceType computeType(compiler) { 1044 InterfaceType computeType(compiler) {
1038 if (type == null) { 1045 if (type == null) {
1039 ClassNode node = parseNode(compiler); 1046 ClassNode node = parseNode(compiler);
1040 Link<Type> parameters = 1047 Link<Type> parameters =
1041 TypeDeclarationElement.createTypeVariables(this, node.typeParameters); 1048 TypeDeclarationElement.createTypeVariables(this, node.typeParameters);
1042 type = new InterfaceType(this, parameters); 1049 type = new InterfaceType(this, parameters);
1043 } 1050 }
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
1412 Node parseNode(compiler) => cachedNode; 1419 Node parseNode(compiler) => cachedNode;
1413 1420
1414 String toString() => "${enclosingElement.toString()}.${name.slowToString()}"; 1421 String toString() => "${enclosingElement.toString()}.${name.slowToString()}";
1415 1422
1416 TypeVariableElement cloneTo(Element enclosing, DiagnosticListener listener) { 1423 TypeVariableElement cloneTo(Element enclosing, DiagnosticListener listener) {
1417 TypeVariableElement result = 1424 TypeVariableElement result =
1418 new TypeVariableElement(name, enclosing, node, type, bound); 1425 new TypeVariableElement(name, enclosing, node, type, bound);
1419 return result; 1426 return result;
1420 } 1427 }
1421 } 1428 }
OLDNEW
« 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