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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import 'dart:collection'; 5 import 'dart:collection';
6 6
7 /// Helpers for Analyzer's Element model and corelib model. 7 /// Helpers for Analyzer's Element model and corelib model.
8 8
9 import 'package:analyzer/dart/ast/ast.dart' 9 import 'package:analyzer/dart/ast/ast.dart'
10 show 10 show
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 List<ClassElement> getImmediateSuperclasses(ClassElement c) { 148 List<ClassElement> getImmediateSuperclasses(ClassElement c) {
149 var result = <ClassElement>[]; 149 var result = <ClassElement>[];
150 for (var m in c.mixins.reversed) { 150 for (var m in c.mixins.reversed) {
151 result.add(m.element); 151 result.add(m.element);
152 } 152 }
153 var s = c.supertype; 153 var s = c.supertype;
154 if (s != null) result.add(s.element); 154 if (s != null) result.add(s.element);
155 return result; 155 return result;
156 } 156 }
157 157
158 /// Returns true if the library [l] is dart:_runtime.
159 // TODO(jmesserly): unlike other methods in this file, this one wouldn't be
160 // suitable for upstream to Analyzer, as it's DDC specific.
158 bool isSdkInternalRuntime(LibraryElement l) => 161 bool isSdkInternalRuntime(LibraryElement l) =>
159 l.isInSdk && l.source.uri.toString() == 'dart:_runtime'; 162 l.isInSdk && l.source.uri.toString() == 'dart:_runtime';
163
164 /// Return `true` if the given [classElement] has a noSuchMethod() method
165 /// distinct from the one declared in class Object, as per the Dart Language
166 /// Specification (section 10.4).
167 // TODO(jmesserly): this was taken from error_verifier.dart
168 bool hasNoSuchMethod(ClassElement classElement) {
169 // TODO(jmesserly): this is slow in Analyzer. It's a linear scan through all
170 // methods, up through the class hierarchy.
171 var method = classElement.lookUpMethod(
172 FunctionElement.NO_SUCH_METHOD_METHOD_NAME, classElement.library);
173 var definingClass = method?.enclosingElement;
174 return definingClass != null && !definingClass.type.isObject;
175 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698