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

Side by Side Diff: lib/type_checker.dart

Issue 2466373002: Type check untyped == calls specially. (Closed)
Patch Set: 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 | « no previous file | testcases/strong-mode/escape.baseline.txt » ('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 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 } 454 }
455 } 455 }
456 return instantiation.substituteType(function.returnType); 456 return instantiation.substituteType(function.returnType);
457 } 457 }
458 458
459 @override 459 @override
460 DartType visitMethodInvocation(MethodInvocation node) { 460 DartType visitMethodInvocation(MethodInvocation node) {
461 var target = node.interfaceTarget; 461 var target = node.interfaceTarget;
462 if (target == null) { 462 if (target == null) {
463 var receiver = visitExpression(node.receiver); 463 var receiver = visitExpression(node.receiver);
464 return (node.name.name == 'call' && receiver is FunctionType) 464 if (node.name.name == '==') {
465 ? handleFunctionCall(node, receiver, node.arguments) 465 visitExpression(node.arguments.positional.single);
466 : handleDynamicCall(receiver, node.arguments); 466 return environment.boolType;
ahe 2016/11/01 16:52:24 I don't see how you know that you can return bool
asgerf 2016/11/01 17:07:33 In strong mode (which is what we are checking), op
467 }
468 if (node.name.name == 'call' && receiver is FunctionType) {
469 return handleFunctionCall(node, receiver, node.arguments);
470 }
471 return handleDynamicCall(receiver, node.arguments);
467 } else if (environment.isOverloadedArithmeticOperator(target)) { 472 } else if (environment.isOverloadedArithmeticOperator(target)) {
468 assert(node.arguments.positional.length == 1); 473 assert(node.arguments.positional.length == 1);
469 var receiver = visitExpression(node.receiver); 474 var receiver = visitExpression(node.receiver);
470 var argument = visitExpression(node.arguments.positional[0]); 475 var argument = visitExpression(node.arguments.positional[0]);
471 return environment.getTypeOfOverloadedArithmetic(receiver, argument); 476 return environment.getTypeOfOverloadedArithmetic(receiver, argument);
472 } else { 477 } else {
473 return handleCall(node.arguments, target.function, 478 return handleCall(node.arguments, target.function,
474 receiver: getReceiverType(node, node.receiver, node.interfaceTarget)); 479 receiver: getReceiverType(node, node.receiver, node.interfaceTarget));
475 } 480 }
476 } 481 }
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
795 } 800 }
796 801
797 @override 802 @override
798 visitLocalInitializer(LocalInitializer node) { 803 visitLocalInitializer(LocalInitializer node) {
799 visitVariableDeclaration(node.variable); 804 visitVariableDeclaration(node.variable);
800 } 805 }
801 806
802 @override 807 @override
803 visitInvalidInitializer(InvalidInitializer node) {} 808 visitInvalidInitializer(InvalidInitializer node) {}
804 } 809 }
OLDNEW
« no previous file with comments | « no previous file | testcases/strong-mode/escape.baseline.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698