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

Unified Diff: lib/src/checker/rules.dart

Issue 1038583004: Rationalize coercions (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Rebase Created 5 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/src/checker/checker.dart ('k') | lib/src/codegen/reify_coercions.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/checker/rules.dart
diff --git a/lib/src/checker/rules.dart b/lib/src/checker/rules.dart
index cbca57a9335351247d3f6e9902e1741d584e2c4e..871c52ae514d830c1e7b3209e9f87d564329d713 100644
--- a/lib/src/checker/rules.dart
+++ b/lib/src/checker/rules.dart
@@ -393,7 +393,7 @@ class RestrictedRules extends TypeRules {
final n2s = toT.namedParameterTypes;
final ret2 = toT.returnType;
- Coercion ret = _coerceTo(ret1, ret2, true);
+ Coercion ret = _coerceTo(ret1, ret2, options.wrapClosures);
// Reject if one has named and the other has optional
if (n1s.length > 0 && o2s.length > 0) return Coercion.error();
@@ -456,12 +456,6 @@ class RestrictedRules extends TypeRules {
// fromT <: toT, no coercion needed
if (isSubTypeOf(fromT, toT)) return Coercion.identity(toT);
- // Downcasting from dynamic to object always succeeds,
- // no coercion needed.
- if (fromT.isDynamic && toT == provider.objectType) {
- return Coercion.identity(toT);
- }
-
// For now, we always wrap closures.
if (wrap && fromT is FunctionType && toT is FunctionType) {
return _wrapTo(fromT, toT);
@@ -494,7 +488,7 @@ class RestrictedRules extends TypeRules {
StaticInfo checkAssignment(Expression expr, DartType toT, bool constContext) {
final fromT = getStaticType(expr);
- final Coercion c = _coerceTo(fromT, toT, true);
+ final Coercion c = _coerceTo(fromT, toT, options.wrapClosures);
if (c is Identity) return null;
if (c is CoercionError) return new StaticTypeError(this, expr, toT);
if (constContext && !options.allowConstCasts) {
« no previous file with comments | « lib/src/checker/checker.dart ('k') | lib/src/codegen/reify_coercions.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698