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

Unified Diff: lib/compiler/implementation/elements/elements.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: 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
Index: lib/compiler/implementation/elements/elements.dart
diff --git a/lib/compiler/implementation/elements/elements.dart b/lib/compiler/implementation/elements/elements.dart
index b3b0fe1244ce38c34a44862a21098b5390c14576..a3016fb9b091328566fcfbfe46499f51de9d9284 100644
--- a/lib/compiler/implementation/elements/elements.dart
+++ b/lib/compiler/implementation/elements/elements.dart
@@ -698,7 +698,7 @@ class AbstractFieldElement extends Element {
//
// We need to make sure that the position returned is relative to
// the compilation unit of the abstract element.
- if (getter !== null
+ if (getter !== null
&& getter.getCompilationUnit() === getCompilationUnit()) {
return getter.position();
} else {
@@ -1053,13 +1053,22 @@ class ClassElement extends ScopeContainerElement
}
/**
- * Lookup super members for the class. This will ignore constructors.
+ * Lookup super members for the class. This will ignore constructors.
*/
Element lookupSuperMember(SourceString memberName) {
+ return lookupSuperMemberInLibrary(memberName, getLibrary());
+ }
+
+ /**
+ * Lookup super members for the class that is accessible in [library].
+ * This will ignore constructors.
+ */
+ Element lookupSuperMemberInLibrary(SourceString memberName,
kasperl 2012/08/16 12:47:57 Would it be possible to start using Selector for l
floitsch 2012/08/16 16:15:55 Went a little bit into that direction. It's not co
+ LibraryElement library) {
bool isPrivate = memberName.isPrivate();
for (ClassElement s = superclass; s != null; s = s.superclass) {
// Private members from a different library are not visible.
- if (isPrivate && getLibrary() !== s.getLibrary()) continue;
+ if (isPrivate && library !== s.getLibrary()) continue;
Element e = s.lookupLocalMember(memberName);
if (e === null) continue;
// Static members are not inherited.
@@ -1071,6 +1080,25 @@ class ClassElement extends ScopeContainerElement
/**
* Find the first member in the class chain with the given
+ * [memberName] that is accessible from within [library]. If the
+ * [memberName] is not private then the [library] can be `null`.
+ *
+ * This method is NOT to be used for resolving
+ * unqualified sends because it does not implement the scoping
+ * rules, where library scope comes before superclass scope.
+ */
+ Element lookupMemberInLibrary(SourceString memberName,
+ LibraryElement library) {
+ Element localMember = lookupLocalMember(memberName);
+ if (localMember != null &&
+ (!memberName.isPrivate() || getLibrary() == library)) {
+ return localMember;
+ }
+ return lookupSuperMemberInLibrary(memberName, library);
+ }
+
+ /**
+ * Find the first member in the class chain with the given
* [memberName]. This method is NOT to be used for resolving
* unqualified sends because it does not implement the scoping
* rules, where library scope comes before superclass scope.
« no previous file with comments | « no previous file | lib/compiler/implementation/ssa/optimize.dart » ('j') | lib/compiler/implementation/ssa/optimize.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698