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

Side by Side Diff: pkg/analyzer/lib/src/summary/summary_sdk.dart

Issue 2581803002: Add access to FutureOr in TypeProviders (and add implementation in mock sdks) (Closed)
Patch Set: Created 4 years 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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 library analyzer.src.summary.summary_sdk; 5 library analyzer.src.summary.summary_sdk;
6 6
7 import 'package:analyzer/dart/element/element.dart'; 7 import 'package:analyzer/dart/element/element.dart';
8 import 'package:analyzer/dart/element/type.dart'; 8 import 'package:analyzer/dart/element/type.dart';
9 import 'package:analyzer/file_system/file_system.dart' show ResourceProvider; 9 import 'package:analyzer/file_system/file_system.dart' show ResourceProvider;
10 import 'package:analyzer/src/context/cache.dart' show CacheEntry; 10 import 'package:analyzer/src/context/cache.dart' show CacheEntry;
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 class SummaryTypeProvider extends TypeProviderBase { 193 class SummaryTypeProvider extends TypeProviderBase {
194 LibraryElement _coreLibrary; 194 LibraryElement _coreLibrary;
195 LibraryElement _asyncLibrary; 195 LibraryElement _asyncLibrary;
196 196
197 InterfaceType _boolType; 197 InterfaceType _boolType;
198 InterfaceType _deprecatedType; 198 InterfaceType _deprecatedType;
199 InterfaceType _doubleType; 199 InterfaceType _doubleType;
200 InterfaceType _functionType; 200 InterfaceType _functionType;
201 InterfaceType _futureDynamicType; 201 InterfaceType _futureDynamicType;
202 InterfaceType _futureNullType; 202 InterfaceType _futureNullType;
203 InterfaceType _futureOrType;
203 InterfaceType _futureType; 204 InterfaceType _futureType;
204 InterfaceType _intType; 205 InterfaceType _intType;
205 InterfaceType _iterableDynamicType; 206 InterfaceType _iterableDynamicType;
206 InterfaceType _iterableType; 207 InterfaceType _iterableType;
207 InterfaceType _listType; 208 InterfaceType _listType;
208 InterfaceType _mapType; 209 InterfaceType _mapType;
209 DartObjectImpl _nullObject; 210 DartObjectImpl _nullObject;
210 InterfaceType _nullType; 211 InterfaceType _nullType;
211 InterfaceType _numType; 212 InterfaceType _numType;
212 InterfaceType _objectType; 213 InterfaceType _objectType;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 } 260 }
260 261
261 @override 262 @override
262 InterfaceType get futureNullType { 263 InterfaceType get futureNullType {
263 assert(_asyncLibrary != null); 264 assert(_asyncLibrary != null);
264 _futureNullType ??= futureType.instantiate(<DartType>[nullType]); 265 _futureNullType ??= futureType.instantiate(<DartType>[nullType]);
265 return _futureNullType; 266 return _futureNullType;
266 } 267 }
267 268
268 @override 269 @override
270 InterfaceType get futureOrType {
271 assert(_asyncLibrary != null);
272 _futureOrType ??= _getType(_asyncLibrary, "FutureOr");
273 return _futureOrType;
274 }
275
276 @override
269 InterfaceType get futureType { 277 InterfaceType get futureType {
270 assert(_asyncLibrary != null); 278 assert(_asyncLibrary != null);
271 _futureType ??= _getType(_asyncLibrary, "Future"); 279 _futureType ??= _getType(_asyncLibrary, "Future");
272 return _futureType; 280 return _futureType;
273 } 281 }
274 282
275 @override 283 @override
276 InterfaceType get intType { 284 InterfaceType get intType {
277 assert(_coreLibrary != null); 285 assert(_coreLibrary != null);
278 _intType ??= _getType(_coreLibrary, "int"); 286 _intType ??= _getType(_coreLibrary, "int");
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 * throw a [StateError] if there is no class with the given name. 412 * throw a [StateError] if there is no class with the given name.
405 */ 413 */
406 InterfaceType _getType(LibraryElement library, String name) { 414 InterfaceType _getType(LibraryElement library, String name) {
407 Element element = library.getType(name); 415 Element element = library.getType(name);
408 if (element == null) { 416 if (element == null) {
409 throw new StateError("No definition of type $name"); 417 throw new StateError("No definition of type $name");
410 } 418 }
411 return (element as ClassElement).type; 419 return (element as ClassElement).type;
412 } 420 }
413 } 421 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698