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

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

Issue 10915171: Don't report 'no such method' if class defines 'noSuchMethod' (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add preference Created 8 years, 3 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
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 18ef336ea63978e03b75bc524726d664b510ce95..a1489db4597bff2b6ff584eeb425fbe3e660b09b 100644
--- a/compiler/java/com/google/dart/compiler/resolver/Elements.java
+++ b/compiler/java/com/google/dart/compiler/resolver/Elements.java
@@ -35,6 +35,7 @@ import com.google.dart.compiler.common.SourceInfo;
import com.google.dart.compiler.parser.Token;
import com.google.dart.compiler.resolver.LabelElement.LabeledStatementType;
import com.google.dart.compiler.type.InterfaceType;
+import com.google.dart.compiler.type.InterfaceType.Member;
import com.google.dart.compiler.type.Type;
import com.google.dart.compiler.type.TypeVariable;
import com.google.dart.compiler.util.Paths;
@@ -703,19 +704,33 @@ static FieldElementImplementation fieldFromNode(DartField node,
/**
* @return <code>true</code> if given {@link Source} represents library with given name.
*/
- public static boolean isLibrarySource(Source source, String name) {
+ private static boolean isLibrarySource(Source source, String name) {
if (source instanceof DartSource) {
DartSource dartSource = (DartSource) source;
LibrarySource library = dartSource.getLibrary();
if (library != null) {
String libraryName = library.getName();
- return libraryName.endsWith("/core/" + name);
+ return libraryName.endsWith(name);
}
}
return false;
}
/**
+ * @return <code>true</code> if given {@link Source} represents code library declaration or
+ * implementation.
+ */
+ public static boolean isCoreLibrarySource(Source source) {
+ // TODO (danrubel) remove these when dartc libraries are removed
+ // Old core library file names
+ return Elements.isLibrarySource(source, "/core/corelib.dart")
+ || Elements.isLibrarySource(source, "/core/corelib_impl.dart")
+ // New core library file names
+ || Elements.isLibrarySource(source, "/core/core.dart")
+ || Elements.isLibrarySource(source, "/core/coreimpl.dart");
+ }
+
+ /**
* @return the {@link LibraryElement} which declares given {@link Element}.
*/
public static LibraryElement getDeclaringLibrary(Element element) {
@@ -830,4 +845,16 @@ static FieldElementImplementation fieldFromNode(DartField node,
Modifiers modifiers = field.getModifiers();
return modifiers.isStatic() || modifiers.isConstant();
}
+
+ /**
+ * @return <code>true</code> if given {@link InterfaceType} overrides "noSuchMethod".
+ */
+ public static boolean handlesNoSuchMethod(InterfaceType type) {
+ Member member = type.lookupMember("noSuchMethod");
+ if (member == null) {
+ return false;
+ }
+ Source source = member.getElement().getSourceInfo().getSource();
+ return !isCoreLibrarySource(source);
+ }
}

Powered by Google App Engine
This is Rietveld 408576698