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

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

Issue 957013002: Typecheck map and list literals (Closed) Base URL: git@github.com:dart-lang/dart-dev-compiler.git@master
Patch Set: Rebase Created 5 years, 10 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/options.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 6ec3c2ac03e7006e9be555af5432d4c973f16e62..8c9608bd1c4d8e7bc6f3623f7ca1185f7a369efc 100644
--- a/lib/src/checker/rules.dart
+++ b/lib/src/checker/rules.dart
@@ -35,7 +35,7 @@ abstract class TypeRules {
bool isNonNullableType(DartType t) => false;
bool maybeNonNullableType(DartType t) => false;
- StaticInfo checkAssignment(Expression expr, DartType t);
+ StaticInfo checkAssignment(Expression expr, DartType t, bool constContext);
DartType getStaticType(Expression expr) => expr.staticType;
@@ -58,7 +58,8 @@ class DartRules extends TypeRules {
return t1.isAssignableTo(t2);
}
- StaticInfo checkAssignment(Expression expr, DartType toType) {
+ StaticInfo checkAssignment(
+ Expression expr, DartType toType, bool constContext) {
final fromType = getStaticType(expr);
if (!isAssignable(fromType, toType)) {
return new StaticTypeError(this, expr, toType);
@@ -455,13 +456,17 @@ class RestrictedRules extends TypeRules {
return Coercion.error();
}
- StaticInfo checkAssignment(Expression expr, DartType toT) {
+ StaticInfo checkAssignment(Expression expr, DartType toT, bool constContext) {
final fromT = getStaticType(expr);
final Coercion c = _coerceTo(fromT, toT, true);
+ if (c is Identity) return null;
if (c is CoercionError) return new StaticTypeError(this, expr, toT);
+ if (constContext && !options.allowConstCasts) {
+ return new StaticTypeError(this, expr, toT);
+ }
if (c is Cast) return DownCast.create(this, expr, c);
if (c is Wrapper) return ClosureWrap.create(this, expr, c, toT);
- assert(c is Identity);
+ assert(false);
return null;
}
« no previous file with comments | « lib/src/checker/checker.dart ('k') | lib/src/options.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698