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

Side by Side Diff: lib/type_checker.dart

Issue 2465263002: Always store the type of a conditional expression on the node. (Closed)
Patch Set: Update test expectation Created 4 years, 1 month 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
« no previous file with comments | « lib/frontend/accessors.dart ('k') | testcases/input/null_aware.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 library kernel.type_checker; 4 library kernel.type_checker;
5 5
6 import 'ast.dart'; 6 import 'ast.dart';
7 import 'class_hierarchy.dart'; 7 import 'class_hierarchy.dart';
8 import 'core_types.dart'; 8 import 'core_types.dart';
9 import 'type_algebra.dart'; 9 import 'type_algebra.dart';
10 import 'type_environment.dart'; 10 import 'type_environment.dart';
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 } 312 }
313 313
314 @override 314 @override
315 DartType visitBoolLiteral(BoolLiteral node) { 315 DartType visitBoolLiteral(BoolLiteral node) {
316 return environment.boolType; 316 return environment.boolType;
317 } 317 }
318 318
319 @override 319 @override
320 DartType visitConditionalExpression(ConditionalExpression node) { 320 DartType visitConditionalExpression(ConditionalExpression node) {
321 checkAssignableExpression(node.condition, environment.boolType); 321 checkAssignableExpression(node.condition, environment.boolType);
322 if (node.staticType == null) { 322 checkAssignableExpression(node.then, node.staticType);
323 var thenType = visitExpression(node.then); 323 checkAssignableExpression(node.otherwise, node.staticType);
324 var otherwiseType = visitExpression(node.otherwise); 324 return node.staticType;
325 if (thenType is BottomType) return otherwiseType;
326 if (otherwiseType is BottomType) return thenType;
327 return const DynamicType();
328 } else {
329 checkAssignableExpression(node.then, node.staticType);
330 checkAssignableExpression(node.otherwise, node.staticType);
331 return node.staticType;
332 }
333 } 325 }
334 326
335 @override 327 @override
336 DartType visitConstructorInvocation(ConstructorInvocation node) { 328 DartType visitConstructorInvocation(ConstructorInvocation node) {
337 Constructor target = node.target; 329 Constructor target = node.target;
338 Arguments arguments = node.arguments; 330 Arguments arguments = node.arguments;
339 Class class_ = target.enclosingClass; 331 Class class_ = target.enclosingClass;
340 handleCall(arguments, target.function, 332 handleCall(arguments, target.function,
341 typeParameters: class_.typeParameters); 333 typeParameters: class_.typeParameters);
342 return new InterfaceType(target.enclosingClass, arguments.types); 334 return new InterfaceType(target.enclosingClass, arguments.types);
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
803 } 795 }
804 796
805 @override 797 @override
806 visitLocalInitializer(LocalInitializer node) { 798 visitLocalInitializer(LocalInitializer node) {
807 visitVariableDeclaration(node.variable); 799 visitVariableDeclaration(node.variable);
808 } 800 }
809 801
810 @override 802 @override
811 visitInvalidInitializer(InvalidInitializer node) {} 803 visitInvalidInitializer(InvalidInitializer node) {}
812 } 804 }
OLDNEW
« no previous file with comments | « lib/frontend/accessors.dart ('k') | testcases/input/null_aware.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698