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

Unified Diff: pkg/dev_compiler/lib/src/compiler/element_helpers.dart

Issue 2803673007: fix #29233, final fields can be settable in a mock (Closed)
Patch Set: fix Created 3 years, 8 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: 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;
+}

Powered by Google App Engine
This is Rietveld 408576698