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

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

Issue 10827359: Fix field-accesses for private fields that were "shadowed" by other private fields. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update comments. 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 | « lib/compiler/implementation/ssa/optimize.dart ('k') | tests/language/private1.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/world.dart
diff --git a/lib/compiler/implementation/world.dart b/lib/compiler/implementation/world.dart
index 03e4e3a1906aa52d95b2ffbe54361c1c4aef6f59..38615cca942e177f64673b850199e8a4c06ed74f 100644
--- a/lib/compiler/implementation/world.dart
+++ b/lib/compiler/implementation/world.dart
@@ -29,20 +29,25 @@ class World {
}
/**
- * Returns a [MemberSet] that contains the possible targets of a
- * selector named [member] on a receiver whose type is [type].
+ * Returns a [MemberSet] that contains the possible targets of the given
+ * [selector] on a receiver with the given [type].
*/
- MemberSet _memberSetFor(Type type, SourceString member) {
+ MemberSet _memberSetFor(Type type, Selector selector) {
assert(compiler !== null);
ClassElement cls = type.element;
- MemberSet result = new MemberSet(member);
- Element element = cls.lookupMember(member);
+ SourceString name = selector.name;
+ LibraryElement library = selector.library;
+ MemberSet result = new MemberSet(name);
+ Element element = cls.lookupSelector(selector);
if (element !== null) result.add(element);
+ bool isPrivate = name.isPrivate();
Set<ClassElement> subtypesOfCls = subtypes[cls];
if (subtypesOfCls !== null) {
for (ClassElement sub in subtypesOfCls) {
- element = sub.lookupLocalMember(member);
+ // Private members from a different library are not visible.
+ if (isPrivate && sub.getLibrary() != library) continue;
+ element = sub.lookupLocalMember(name);
if (element !== null) result.add(element);
}
}
@@ -50,11 +55,11 @@ class World {
}
/**
- * Returns the single field with the given name, if such a field
- * exists. If there are multple fields, or none, return null.
+ * Returns the single field with the given [selector]. If there is no such
+ * field, or there are multiple possible fields returns [:null:].
*/
- VariableElement locateSingleField(Type type, SourceString member) {
- MemberSet memberSet = _memberSetFor(type, member);
+ VariableElement locateSingleField(Type type, Selector selector) {
+ MemberSet memberSet = _memberSetFor(type, selector);
int fieldCount = 0;
int nonFieldCount = 0;
VariableElement field;
@@ -71,8 +76,8 @@ class World {
Set<ClassElement> findNoSuchMethodHolders(Type type) {
Set<ClassElement> result = new Set<ClassElement>();
- MemberSet memberSet = _memberSetFor(type, Compiler.NO_SUCH_METHOD);
Selector noSuchMethodSelector = new Selector.noSuchMethod();
+ MemberSet memberSet = _memberSetFor(type, noSuchMethodSelector);
for (Element element in memberSet.elements) {
ClassElement holder = element.getEnclosingClass();
if (holder !== compiler.objectClass &&
« no previous file with comments | « lib/compiler/implementation/ssa/optimize.dart ('k') | tests/language/private1.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698