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

Unified Diff: sdk/lib/_internal/compiler/implementation/elements/modelx.dart

Issue 13521008: Handle private fields from mixins. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Test added Created 7 years, 8 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 | tests/language/language_dart2js.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/compiler/implementation/elements/modelx.dart
diff --git a/sdk/lib/_internal/compiler/implementation/elements/modelx.dart b/sdk/lib/_internal/compiler/implementation/elements/modelx.dart
index 0a3b141791e79d26aac3b2b85613e227b0fb94de..8e9bf312151ad629658b80ebcdb76d50a272ddfa 100644
--- a/sdk/lib/_internal/compiler/implementation/elements/modelx.dart
+++ b/sdk/lib/_internal/compiler/implementation/elements/modelx.dart
@@ -1530,7 +1530,7 @@ abstract class BaseClassElementX extends ElementX implements ClassElement {
Element lookupSuperSelector(Selector selector) {
return internalLookupSelector(selector, true);
}
-
+
Element internalLookupSelector(Selector selector, bool isSuperLookup) {
SourceString name = selector.name;
bool isPrivate = name.isPrivate();
@@ -1583,24 +1583,25 @@ abstract class BaseClassElementX extends ElementX implements ClassElement {
*/
bool isShadowedByField(Element fieldMember) {
assert(fieldMember.isField());
- // Note that we cannot use [lookupMember] or [lookupSuperMember] since it
- // will not do the right thing for private elements.
- ClassElement lookupClass = this;
+ SourceString fieldName = fieldMember.name;
+ bool isPrivate = fieldName.isPrivate();
LibraryElement memberLibrary = fieldMember.getLibrary();
- if (fieldMember.name.isPrivate()) {
- // We find a super class in the same library as the field. This way the
- // lookupMember will work.
- while (lookupClass.getLibrary() != memberLibrary) {
- lookupClass = lookupClass.superclass;
+ ClassElement lookupClass = this;
+ while (lookupClass != null) {
+ Element foundMember = lookupClass.lookupLocalMember(fieldName);
+ if (foundMember != null) {
+ if (foundMember == fieldMember) return false;
+ if (foundMember.isField()) {
+ if (!isPrivate || memberLibrary == foundMember.getLibrary()) {
+ // Private fields can only be shadowed by a field declared
+ // in the same library.
+ return true;
+ }
+ }
}
+ lookupClass = lookupClass.superclass;
}
- SourceString fieldName = fieldMember.name;
- while (true) {
- Element foundMember = lookupClass.lookupMember(fieldName);
- if (foundMember == fieldMember) return false;
- if (foundMember.isField()) return true;
- lookupClass = foundMember.getEnclosingClass().superclass;
- }
+ return false;
}
Element validateConstructorLookupResults(Selector selector,
« no previous file with comments | « no previous file | tests/language/language_dart2js.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698