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

Side by Side Diff: lib/src/checker/rules.dart

Issue 1172453002: fixes #209, remove tree mutation from CodeChecker (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 6 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) 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 dev_compiler.src.checker.rules; 5 library dev_compiler.src.checker.rules;
6 6
7 import 'package:analyzer/src/generated/ast.dart'; 7 import 'package:analyzer/src/generated/ast.dart';
8 import 'package:analyzer/src/generated/element.dart'; 8 import 'package:analyzer/src/generated/element.dart';
9 import 'package:analyzer/src/generated/resolver.dart'; 9 import 'package:analyzer/src/generated/resolver.dart';
10 10
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 527
528 /// Downward inference 528 /// Downward inference
529 bool _inferExpression(Expression e, DartType t, List<String> errors, 529 bool _inferExpression(Expression e, DartType t, List<String> errors,
530 {cast: true}) { 530 {cast: true}) {
531 if (e is ConditionalExpression) { 531 if (e is ConditionalExpression) {
532 return _inferConditionalExpression(e, t, errors); 532 return _inferConditionalExpression(e, t, errors);
533 } 533 }
534 if (e is ParenthesizedExpression) { 534 if (e is ParenthesizedExpression) {
535 return _inferParenthesizedExpression(e, t, errors); 535 return _inferParenthesizedExpression(e, t, errors);
536 } 536 }
537 if (e is Conversion) return _inferExpression(e.node, t, errors);
538 if (rules.isSubTypeOf(rules.getStaticType(e), t)) return true; 537 if (rules.isSubTypeOf(rules.getStaticType(e), t)) return true;
539 if (cast && rules.getStaticType(e).isDynamic) { 538 if (cast && rules.getStaticType(e).isDynamic) {
540 annotateCastFromDynamic(e, t); 539 annotateCastFromDynamic(e, t);
541 return true; 540 return true;
542 } 541 }
543 if (e is FunctionExpression) return _inferFunctionExpression(e, t, errors); 542 if (e is FunctionExpression) return _inferFunctionExpression(e, t, errors);
544 if (e is ListLiteral) return _inferListLiteral(e, t, errors); 543 if (e is ListLiteral) return _inferListLiteral(e, t, errors);
545 if (e is MapLiteral) return _inferMapLiteral(e, t, errors); 544 if (e is MapLiteral) return _inferMapLiteral(e, t, errors);
546 if (e is NamedExpression) return _inferNamedExpression(e, t, errors); 545 if (e is NamedExpression) return _inferNamedExpression(e, t, errors);
547 if (e is InstanceCreationExpression) { 546 if (e is InstanceCreationExpression) {
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
782 var entries = e.entries; 781 var entries = e.entries;
783 bool inferEntry(MapLiteralEntry entry) { 782 bool inferEntry(MapLiteralEntry entry) {
784 return _inferExpression(entry.key, kType, errors) && 783 return _inferExpression(entry.key, kType, errors) &&
785 _inferExpression(entry.value, vType, errors); 784 _inferExpression(entry.value, vType, errors);
786 } 785 }
787 var b = entries.every(inferEntry); 786 var b = entries.every(inferEntry);
788 if (b) annotateMapLiteral(e, targs); 787 if (b) annotateMapLiteral(e, targs);
789 return b; 788 return b;
790 } 789 }
791 } 790 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698