Index: pkg/dev_compiler/lib/src/compiler/element_helpers.dart |
diff --git a/pkg/dev_compiler/lib/src/compiler/element_helpers.dart b/pkg/dev_compiler/lib/src/compiler/element_helpers.dart |
index 79b3feb173e4626936d1840aea8a640a4769f020..0937565ae7f1e3691c226841728ddc61351abde6 100644 |
--- a/pkg/dev_compiler/lib/src/compiler/element_helpers.dart |
+++ b/pkg/dev_compiler/lib/src/compiler/element_helpers.dart |
@@ -155,5 +155,21 @@ List<ClassElement> getImmediateSuperclasses(ClassElement c) { |
return result; |
} |
+/// Returns true if the library [l] is dart:_runtime. |
+// TODO(jmesserly): unlike other methods in this file, this one wouldn't be |
+// suitable for upstream to Analyzer, as it's DDC specific. |
bool isSdkInternalRuntime(LibraryElement l) => |
l.isInSdk && l.source.uri.toString() == 'dart:_runtime'; |
+ |
+/// Return `true` if the given [classElement] has a noSuchMethod() method |
+/// distinct from the one declared in class Object, as per the Dart Language |
+/// Specification (section 10.4). |
+// TODO(jmesserly): this was taken from error_verifier.dart |
+bool hasNoSuchMethod(ClassElement classElement) { |
+ // TODO(jmesserly): this is slow in Analyzer. It's a linear scan through all |
+ // methods, up through the class hierarchy. |
+ var method = classElement.lookUpMethod( |
+ FunctionElement.NO_SUCH_METHOD_METHOD_NAME, classElement.library); |
+ var definingClass = method?.enclosingElement; |
+ return definingClass != null && !definingClass.type.isObject; |
+} |