Chromium Code Reviews| Index: lib/compiler/implementation/world.dart |
| diff --git a/lib/compiler/implementation/world.dart b/lib/compiler/implementation/world.dart |
| index 03e4e3a1906aa52d95b2ffbe54361c1c4aef6f59..afef86402415900c9b4bb30aeb5842ffc6543ec1 100644 |
| --- a/lib/compiler/implementation/world.dart |
| +++ b/lib/compiler/implementation/world.dart |
| @@ -30,18 +30,26 @@ class World { |
| /** |
| * Returns a [MemberSet] that contains the possible targets of a |
| - * selector named [member] on a receiver whose type is [type]. |
| + * selector named [member] accessible from the given [library] on a receiver |
| + * with the given [type]. |
| + * |
| + * The [library] can be `null` if the [member] is not private. |
| */ |
| - MemberSet _memberSetFor(Type type, SourceString member) { |
| + MemberSet _memberSetFor(Type type, |
|
kasperl
2012/08/16 12:47:57
Again it would seem like this could be rewritten w
floitsch
2012/08/16 16:15:55
Done.
|
| + LibraryElement library, |
| + SourceString member) { |
| assert(compiler !== null); |
| ClassElement cls = type.element; |
| MemberSet result = new MemberSet(member); |
| - Element element = cls.lookupMember(member); |
| + Element element = cls.lookupMemberInLibrary(member, library); |
| if (element !== null) result.add(element); |
| + bool isPrivate = member.isPrivate(); |
| Set<ClassElement> subtypesOfCls = subtypes[cls]; |
| if (subtypesOfCls !== null) { |
| for (ClassElement sub in subtypesOfCls) { |
| + // Private members from a different library are not visible. |
| + if (isPrivate && sub.getLibrary() != library) continue; |
| element = sub.lookupLocalMember(member); |
| if (element !== null) result.add(element); |
| } |
| @@ -50,11 +58,14 @@ 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 [name] accessible in the given |
| + * [library]. 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, |
| + LibraryElement library, |
| + SourceString name) { |
| + MemberSet memberSet = _memberSetFor(type, library, name); |
| int fieldCount = 0; |
| int nonFieldCount = 0; |
| VariableElement field; |
| @@ -71,7 +82,7 @@ class World { |
| Set<ClassElement> findNoSuchMethodHolders(Type type) { |
| Set<ClassElement> result = new Set<ClassElement>(); |
| - MemberSet memberSet = _memberSetFor(type, Compiler.NO_SUCH_METHOD); |
| + MemberSet memberSet = _memberSetFor(type, null, Compiler.NO_SUCH_METHOD); |
| Selector noSuchMethodSelector = new Selector.noSuchMethod(); |
| for (Element element in memberSet.elements) { |
| ClassElement holder = element.getEnclosingClass(); |