Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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.modelx; | 5 library elements.modelx; |
| 6 | 6 |
| 7 import 'elements.dart'; | 7 import 'elements.dart'; |
| 8 import '../constants/expressions.dart'; | 8 import '../constants/expressions.dart'; |
| 9 import '../helpers/helpers.dart'; // Included for debug helpers. | 9 import '../helpers/helpers.dart'; // Included for debug helpers. |
| 10 import '../tree/tree.dart'; | 10 import '../tree/tree.dart'; |
| 11 import '../util/util.dart'; | 11 import '../util/util.dart'; |
| 12 import '../resolution/resolution.dart'; | 12 import '../resolution/resolution.dart'; |
| 13 import '../resolution/class_members.dart' show ClassMemberMixin; | 13 import '../resolution/class_members.dart' show ClassMemberMixin; |
| 14 | 14 |
| 15 import '../dart2jslib.dart' show invariant, | 15 import '../dart2jslib.dart' show |
| 16 InterfaceType, | 16 Backend, |
| 17 DartType, | 17 Compiler, |
| 18 TypeVariableType, | 18 CompilerCancelledException, |
| 19 TypedefType, | 19 Constant, |
| 20 DualKind, | 20 DartType, |
| 21 MessageKind, | 21 DiagnosticListener, |
| 22 DiagnosticListener, | 22 DualKind, |
| 23 Script, | 23 FunctionType, |
| 24 FunctionType, | 24 InterfaceType, |
| 25 Selector, | 25 MessageKind, |
| 26 Constant, | 26 Script, |
| 27 Compiler, | 27 Selector, |
| 28 Backend, | 28 TypeVariableType, |
| 29 isPrivateName; | 29 TypedefType, |
| 30 invariant, | |
| 31 isPrivateName; | |
| 30 | 32 |
| 31 import '../dart_types.dart'; | 33 import '../dart_types.dart'; |
| 32 | 34 |
| 33 import '../scanner/scannerlib.dart' show | 35 import '../scanner/scannerlib.dart' show |
| 34 EOF_TOKEN, | 36 EOF_TOKEN, |
| 35 ErrorToken, | 37 ErrorToken, |
| 36 Token; | 38 Token; |
| 37 | 39 |
| 38 import '../ordered_typeset.dart' show OrderedTypeSet; | 40 import '../ordered_typeset.dart' show OrderedTypeSet; |
| 39 | 41 |
| (...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 484 * element, they are enclosed by the class or compilation unit, as is the | 486 * element, they are enclosed by the class or compilation unit, as is the |
| 485 * abstract field. | 487 * abstract field. |
| 486 */ | 488 */ |
| 487 void addAccessor(FunctionElementX accessor, | 489 void addAccessor(FunctionElementX accessor, |
| 488 Element existing, | 490 Element existing, |
| 489 DiagnosticListener listener) { | 491 DiagnosticListener listener) { |
| 490 void reportError(Element other) { | 492 void reportError(Element other) { |
| 491 listener.reportError(accessor, | 493 listener.reportError(accessor, |
| 492 MessageKind.DUPLICATE_DEFINITION, | 494 MessageKind.DUPLICATE_DEFINITION, |
| 493 {'name': accessor.name}); | 495 {'name': accessor.name}); |
| 494 // TODO(johnniwinther): Make this an info instead of a fatal error. | 496 listener.reportInfo( |
| 495 listener.reportFatalError(other, | 497 other, MessageKind.EXISTING_DEFINITION, {'name': accessor.name}); |
| 496 MessageKind.EXISTING_DEFINITION, | 498 throw new CompilerCancelledException(null); |
|
Johnni Winther
2015/01/06 08:12:04
Add a TODO to let us continue the compilation.
ahe
2015/01/07 12:55:24
Done.
| |
| 497 {'name': accessor.name}); | |
| 498 } | 499 } |
| 499 | 500 |
| 500 if (existing != null) { | 501 if (existing != null) { |
| 501 if (!identical(existing.kind, ElementKind.ABSTRACT_FIELD)) { | 502 if (!identical(existing.kind, ElementKind.ABSTRACT_FIELD)) { |
| 502 reportError(existing); | 503 reportError(existing); |
| 504 return; | |
| 503 } else { | 505 } else { |
| 504 AbstractFieldElementX field = existing; | 506 AbstractFieldElementX field = existing; |
| 505 accessor.abstractField = field; | 507 accessor.abstractField = field; |
| 506 if (accessor.isGetter) { | 508 if (accessor.isGetter) { |
| 507 if (field.getter != null && field.getter != accessor) { | 509 if (field.getter != null && field.getter != accessor) { |
| 508 reportError(field.getter); | 510 reportError(field.getter); |
| 511 return; | |
| 509 } | 512 } |
| 510 field.getter = accessor; | 513 field.getter = accessor; |
| 511 } else { | 514 } else { |
| 512 assert(accessor.isSetter); | 515 assert(accessor.isSetter); |
| 513 if (field.setter != null && field.setter != accessor) { | 516 if (field.setter != null && field.setter != accessor) { |
| 514 reportError(field.setter); | 517 reportError(field.setter); |
| 518 return; | |
| 515 } | 519 } |
| 516 field.setter = accessor; | 520 field.setter = accessor; |
| 517 } | 521 } |
| 518 } | 522 } |
| 519 } else { | 523 } else { |
| 520 Element container = accessor.enclosingClassOrCompilationUnit; | 524 Element container = accessor.enclosingClassOrCompilationUnit; |
| 521 AbstractFieldElementX field = | 525 AbstractFieldElementX field = |
| 522 new AbstractFieldElementX(accessor.name, container); | 526 new AbstractFieldElementX(accessor.name, container); |
| 523 accessor.abstractField = field; | 527 accessor.abstractField = field; |
| 524 if (accessor.isGetter) { | 528 if (accessor.isGetter) { |
| (...skipping 2300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2825 AstElement get definingElement; | 2829 AstElement get definingElement; |
| 2826 | 2830 |
| 2827 bool get hasResolvedAst => definingElement.hasTreeElements; | 2831 bool get hasResolvedAst => definingElement.hasTreeElements; |
| 2828 | 2832 |
| 2829 ResolvedAst get resolvedAst { | 2833 ResolvedAst get resolvedAst { |
| 2830 return new ResolvedAst(declaration, | 2834 return new ResolvedAst(declaration, |
| 2831 definingElement.node, definingElement.treeElements); | 2835 definingElement.node, definingElement.treeElements); |
| 2832 } | 2836 } |
| 2833 | 2837 |
| 2834 } | 2838 } |
| OLD | NEW |