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

Side by Side Diff: pkg/compiler/lib/src/inferrer/type_system.dart

Issue 2718513002: Void is not required to be `null` anymore. (Closed)
Patch Set: Update Kernel code. Created 3 years, 7 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) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, 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 '../common.dart'; 5 import '../common.dart';
6 import '../elements/elements.dart'; 6 import '../elements/elements.dart';
7 import '../elements/entities.dart'; 7 import '../elements/entities.dart';
8 import '../elements/resolution_types.dart' 8 import '../elements/resolution_types.dart'
9 show ResolutionDartType, ResolutionInterfaceType; 9 show ResolutionDartType, ResolutionInterfaceType;
10 import '../tree/dartstring.dart'; 10 import '../tree/dartstring.dart';
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 275
276 /** 276 /**
277 * Returns the intersection between [type] and [annotation]. 277 * Returns the intersection between [type] and [annotation].
278 * [isNullable] indicates whether the annotation implies a null 278 * [isNullable] indicates whether the annotation implies a null
279 * type. 279 * type.
280 */ 280 */
281 TypeInformation narrowType( 281 TypeInformation narrowType(
282 TypeInformation type, ResolutionDartType annotation, 282 TypeInformation type, ResolutionDartType annotation,
283 {bool isNullable: true}) { 283 {bool isNullable: true}) {
284 if (annotation.treatAsDynamic) return type; 284 if (annotation.treatAsDynamic) return type;
285 if (annotation.isVoid) return nullType; 285 if (annotation.isVoid) return type;
286 if (annotation.element == closedWorld.commonElements.objectClass && 286 if (annotation.element == closedWorld.commonElements.objectClass &&
287 isNullable) { 287 isNullable) {
288 return type; 288 return type;
289 } 289 }
290 TypeMask otherType; 290 TypeMask otherType;
291 if (annotation.isTypedef || annotation.isFunctionType) { 291 if (annotation.isTypedef || annotation.isFunctionType) {
292 otherType = functionType.type; 292 otherType = functionType.type;
293 } else if (annotation.isTypeVariable) { 293 } else if (annotation.isTypeVariable) {
294 // TODO(ngeoffray): Narrow to bound. 294 // TODO(ngeoffray): Narrow to bound.
295 return type; 295 return type;
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 TypeMask newType = null; 552 TypeMask newType = null;
553 for (TypeMask mask in list) { 553 for (TypeMask mask in list) {
554 newType = newType == null ? mask : newType.union(mask, closedWorld); 554 newType = newType == null ? mask : newType.union(mask, closedWorld);
555 // Likewise - stop early if we already reach dynamic. 555 // Likewise - stop early if we already reach dynamic.
556 if (newType.containsAll(closedWorld)) return dynamicType; 556 if (newType.containsAll(closedWorld)) return dynamicType;
557 } 557 }
558 558
559 return newType ?? const TypeMask.nonNullEmpty(); 559 return newType ?? const TypeMask.nonNullEmpty();
560 } 560 }
561 } 561 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/inferrer/type_graph_nodes.dart ('k') | pkg/compiler/lib/src/js_backend/checked_mode_helpers.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698