Chromium Code Reviews| 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) { |
|
Johnni Winther
2013/04/04 21:18:36
Using [:lookupClass.getLibrary():] is invalidate b
|
| - 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, |