| Index: compiler/java/com/google/dart/compiler/resolver/Elements.java
|
| diff --git a/compiler/java/com/google/dart/compiler/resolver/Elements.java b/compiler/java/com/google/dart/compiler/resolver/Elements.java
|
| index 06a2078c5b3bec7ff30ee5329f87ef4e607cad48..5fadc578d3218d1d457df7b0012f2b4d76d0b144 100644
|
| --- a/compiler/java/com/google/dart/compiler/resolver/Elements.java
|
| +++ b/compiler/java/com/google/dart/compiler/resolver/Elements.java
|
| @@ -92,13 +92,26 @@ public class Elements {
|
| }
|
|
|
| public static LibraryElement getLibraryElement(Element element) {
|
| - do {
|
| - if (ElementKind.of(element).equals(ElementKind.LIBRARY)) {
|
| - break;
|
| + while (element != null) {
|
| + if (ElementKind.of(element) == ElementKind.LIBRARY) {
|
| + return (LibraryElement) element;
|
| }
|
| - element = element.getEnclosingElement();
|
| - } while (element != null && element.getEnclosingElement() != element);
|
| - return (LibraryElement) element;
|
| + EnclosingElement enclosingElement = element.getEnclosingElement();
|
| + if (enclosingElement == element) {
|
| + return null;
|
| + }
|
| + element = enclosingElement;
|
| + };
|
| + return null;
|
| + }
|
| +
|
| + /**
|
| + * @return <code>true</code> if "a" and "b" are declared in the same {@link LibraryElement}.
|
| + */
|
| + public static boolean areSameLibrary(Element a, Element b) {
|
| + LibraryElement aLibrary = getLibraryElement(a);
|
| + LibraryElement bLibrary = getLibraryElement(b);
|
| + return Objects.equal(aLibrary, bLibrary);
|
| }
|
|
|
| @VisibleForTesting
|
|
|