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

Unified Diff: compiler/java/com/google/dart/compiler/resolver/Elements.java

Issue 10537006: Issue 3266. Produce a warning when trying to call an inaccessible method (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 6 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 | compiler/java/com/google/dart/compiler/resolver/Resolver.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 7325b798ef5a4758ac8ad5b36c8c21a4c180d192..da7c156d409a7a0eefc44b7248c0d3cfd242e13b 100644
--- a/compiler/java/com/google/dart/compiler/resolver/Elements.java
+++ b/compiler/java/com/google/dart/compiler/resolver/Elements.java
@@ -36,6 +36,7 @@ import com.google.dart.compiler.type.InterfaceType;
import com.google.dart.compiler.type.Type;
import com.google.dart.compiler.type.TypeVariable;
import com.google.dart.compiler.util.Paths;
+import com.google.dart.compiler.util.apache.StringUtils;
import java.io.File;
import java.net.URI;
@@ -605,6 +606,29 @@ static FieldElementImplementation fieldFromNode(DartField node,
}
return false;
}
+
+ /**
+ * @return the {@link LibraryElement} which declares given {@link Element}.
+ */
+ public static LibraryElement getDeclaringLibrary(Element element) {
+ while (element != null) {
+ if (element instanceof LibraryElement) {
+ return (LibraryElement) element;
+ }
+ element = element.getEnclosingElement();
+ }
+ return null;
+ }
+
+ /**
+ * @return <code>true</code> if "element" is accessible in "scopeLibrary".
+ */
+ public static boolean isAccessible(LibraryElement scopeLibrary, Element element) {
+ if (element != null && StringUtils.startsWith(element.getName(), "_")) {
+ return Objects.equal(scopeLibrary, getDeclaringLibrary(element));
+ }
+ return true;
+ }
/**
* Looks to see if the property access requires a getter.
« no previous file with comments | « no previous file | compiler/java/com/google/dart/compiler/resolver/Resolver.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698