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

Unified Diff: dart/pkg/compiler/lib/src/elements/modelx.dart

Issue 841303002: Non fatal errors on duplicated accessors (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Merged with r42766. Created 5 years, 11 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 | dart/pkg/compiler/lib/src/resolution/class_members.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/pkg/compiler/lib/src/elements/modelx.dart
diff --git a/dart/pkg/compiler/lib/src/elements/modelx.dart b/dart/pkg/compiler/lib/src/elements/modelx.dart
index 959a5926c73a73afcf0c55ec1a30e6bec712ac3f..9b3bd2eb43cbba0b7c021e28b0fc669bca3e4657 100644
--- a/dart/pkg/compiler/lib/src/elements/modelx.dart
+++ b/dart/pkg/compiler/lib/src/elements/modelx.dart
@@ -15,7 +15,6 @@ import '../resolution/class_members.dart' show ClassMemberMixin;
import '../dart2jslib.dart' show
Backend,
Compiler,
- CompilerCancelledException,
Constant,
DartType,
DiagnosticListener,
@@ -400,7 +399,7 @@ class WarnOnUseElementX extends ElementX implements WarnOnUseElement {
accept(ElementVisitor visitor) => visitor.visitWarnOnUseElement(this);
}
-class AmbiguousElementX extends ElementX implements AmbiguousElement {
+abstract class AmbiguousElementX extends ElementX implements AmbiguousElement {
/**
* The message to report on resolving this element.
*/
@@ -439,6 +438,20 @@ class AmbiguousElementX extends ElementX implements AmbiguousElement {
return set;
}
+ accept(ElementVisitor visitor) => visitor.visitAmbiguousElement(this);
+
+ bool get isTopLevel => false;
+}
+
+/// Element synthesized to diagnose an ambiguous import.
+class AmbiguousImportX extends AmbiguousElementX {
+ AmbiguousImportX(
+ MessageKind messageKind,
+ Map messageArguments,
+ Element enclosingElement, Element existingElement, Element newElement)
+ : super(messageKind, messageArguments, enclosingElement, existingElement,
+ newElement);
+
void diagnose(Element context, DiagnosticListener listener) {
Setlet ambiguousElements = flatten();
MessageKind code = (ambiguousElements.length == 1)
@@ -456,10 +469,16 @@ class AmbiguousElementX extends ElementX implements AmbiguousElement {
});
}
}
+}
- accept(ElementVisitor visitor) => visitor.visitAmbiguousElement(this);
-
- bool get isTopLevel => false;
+/// Element synthesized to recover from a duplicated member of an element.
+class DuplicatedElementX extends AmbiguousElementX {
+ DuplicatedElementX(
+ MessageKind messageKind,
+ Map messageArguments,
+ Element enclosingElement, Element existingElement, Element newElement)
+ : super(messageKind, messageArguments, enclosingElement, existingElement,
+ newElement);
}
class ScopeX {
@@ -509,8 +528,10 @@ class ScopeX {
{'name': accessor.name});
listener.reportInfo(
other, MessageKind.EXISTING_DEFINITION, {'name': accessor.name});
- // TODO(ahe): Don't throw, recover from error.
- throw new CompilerCancelledException(null);
+
+ contents[accessor.name] = new DuplicatedElementX(
+ MessageKind.DUPLICATE_DEFINITION, {'name': accessor.name},
+ accessor.memberContext.enclosingElement, other, accessor);
}
if (existing != null) {
@@ -718,7 +739,7 @@ class ImportScope {
import, MessageKind.HIDDEN_IMPORT, existing, element);
}
} else {
- Element ambiguousElement = new AmbiguousElementX(
+ Element ambiguousElement = new AmbiguousImportX(
MessageKind.DUPLICATE_IMPORT, {'name': name},
enclosingElement, existing, element);
importScope[name] = ambiguousElement;
« no previous file with comments | « no previous file | dart/pkg/compiler/lib/src/resolution/class_members.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698