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

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

Issue 10511008: Support overriding fields with fields. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebased Created 8 years, 6 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 | « dart/lib/compiler/implementation/ssa/optimize.dart ('k') | dart/tests/language/language_dart2js.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/lib/compiler/implementation/world.dart
diff --git a/dart/lib/compiler/implementation/world.dart b/dart/lib/compiler/implementation/world.dart
index 88480cdf6765be1e63d32c0587643327d6fd3bc7..f616c5aa4c892251aa2f5984e0c03e6980e8324a 100644
--- a/dart/lib/compiler/implementation/world.dart
+++ b/dart/lib/compiler/implementation/world.dart
@@ -50,9 +50,24 @@ class World {
return result;
}
- bool isOnlyFields(Type type, SourceString member) {
+ /**
+ * Returns the single field with the given name, if such a field
+ * exists. If there are multple fields, or none, return null.
+ */
+ VariableElement locateSingleField(Type type, SourceString member) {
MemberSet memberSet = _memberSetFor(type, member);
- return !memberSet.isEmpty() && memberSet.hasJustFields();
+ int fieldCount = 0;
+ int nonFieldCount = 0;
+ VariableElement field;
+ memberSet.elements.forEach((Element element) {
+ if (element.isField()) {
+ field = element;
+ fieldCount++;
+ } else {
+ nonFieldCount++;
+ }
+ });
+ return (fieldCount == 1 && nonFieldCount == 0) ? field : null;
}
}
@@ -70,8 +85,4 @@ class MemberSet {
}
bool isEmpty() => elements.isEmpty();
-
- bool hasJustFields() {
- return elements.every((Element element) => element.isField());
- }
}
« no previous file with comments | « dart/lib/compiler/implementation/ssa/optimize.dart ('k') | dart/tests/language/language_dart2js.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698