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

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

Issue 1163393002: remove ignoreTypes flag, to reimplement later, see #134 (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
« no previous file with comments | « no previous file | lib/src/codegen/js_codegen.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) 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 var t = getStaticType(applicand); 68 var t = getStaticType(applicand);
69 if (t is InterfaceType) { 69 if (t is InterfaceType) {
70 return getCallMethodType(t); 70 return getCallMethodType(t);
71 } 71 }
72 if (t is FunctionType) return t; 72 if (t is FunctionType) return t;
73 return null; 73 return null;
74 } 74 }
75 75
76 DartType elementType(Element e); 76 DartType elementType(Element e);
77 77
78 bool isDynamic(DartType t);
79 bool isDynamicTarget(Expression expr); 78 bool isDynamicTarget(Expression expr);
80 bool isDynamicCall(Expression call); 79 bool isDynamicCall(Expression call);
81 } 80 }
82 81
82 // TODO(jmesserly): this is unused.
83 class DartRules extends TypeRules { 83 class DartRules extends TypeRules {
84 DartRules(TypeProvider provider) : super(provider); 84 DartRules(TypeProvider provider) : super(provider);
85 85
86 MissingTypeReporter reportMissingType = null; 86 MissingTypeReporter reportMissingType = null;
87 87
88 bool isSubTypeOf(DartType t1, DartType t2) { 88 bool isSubTypeOf(DartType t1, DartType t2) {
89 return t1.isSubtypeOf(t2); 89 return t1.isSubtypeOf(t2);
90 } 90 }
91 91
92 bool isAssignable(DartType t1, DartType t2) { 92 bool isAssignable(DartType t1, DartType t2) {
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 } 458 }
459 if (c is Cast) return DownCast.create(this, expr, c, reason: reason); 459 if (c is Cast) return DownCast.create(this, expr, c, reason: reason);
460 assert(false); 460 assert(false);
461 return null; 461 return null;
462 } 462 }
463 463
464 DartType elementType(Element e) { 464 DartType elementType(Element e) {
465 return (e as dynamic).type; 465 return (e as dynamic).type;
466 } 466 }
467 467
468 bool isDynamic(DartType t) => options.ignoreTypes || t.isDynamic;
469
470 /// Returns `true` if the target expression is dynamic. 468 /// Returns `true` if the target expression is dynamic.
471 bool isDynamicTarget(Expression target) => 469 // TODO(jmesserly): remove this in favor of utils? Or a static method here?
472 options.ignoreTypes || utils.isDynamicTarget(target); 470 bool isDynamicTarget(Expression target) => utils.isDynamicTarget(target);
473 471
474 /// Returns `true` if the expression is a dynamic function call or method 472 /// Returns `true` if the expression is a dynamic function call or method
475 /// invocation. 473 /// invocation.
476 bool isDynamicCall(Expression call) { 474 bool isDynamicCall(Expression call) {
477 if (options.ignoreTypes) return true;
478 var t = getTypeAsCaller(call); 475 var t = getTypeAsCaller(call);
479 // TODO(leafp): This will currently return true if t is Function 476 // TODO(leafp): This will currently return true if t is Function
480 // This is probably the most correct thing to do for now, since 477 // This is probably the most correct thing to do for now, since
481 // this code is also used by the back end. Maybe revisit at some 478 // this code is also used by the back end. Maybe revisit at some
482 // point? 479 // point?
483 if (t == null) return true; 480 if (t == null) return true;
484 // Dynamic as the parameter type is treated as bottom. A function with 481 // Dynamic as the parameter type is treated as bottom. A function with
485 // a dynamic parameter type requires a dynamic call in general. 482 // a dynamic parameter type requires a dynamic call in general.
486 // However, as an optimization, if we have an original definition, we know 483 // However, as an optimization, if we have an original definition, we know
487 // dynamic is reified as Object - in this case a regular call is fine. 484 // dynamic is reified as Object - in this case a regular call is fine.
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
781 var entries = e.entries; 778 var entries = e.entries;
782 bool inferEntry(MapLiteralEntry entry) { 779 bool inferEntry(MapLiteralEntry entry) {
783 return _inferExpression(entry.key, kType, errors) && 780 return _inferExpression(entry.key, kType, errors) &&
784 _inferExpression(entry.value, vType, errors); 781 _inferExpression(entry.value, vType, errors);
785 } 782 }
786 var b = entries.every(inferEntry); 783 var b = entries.every(inferEntry);
787 if (b) annotateMapLiteral(e, targs); 784 if (b) annotateMapLiteral(e, targs);
788 return b; 785 return b;
789 } 786 }
790 } 787 }
OLDNEW
« no previous file with comments | « no previous file | lib/src/codegen/js_codegen.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698