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

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

Issue 957013002: Typecheck map and list literals (Closed) Base URL: git@github.com:dart-lang/dart-dev-compiler.git@master
Patch Set: Handle partial type instantiations 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 | « no previous file | test/checker/checker_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/checker/checker.dart
diff --git a/lib/src/checker/checker.dart b/lib/src/checker/checker.dart
index f11aef694ff1ac139d46db6066191c78d3d8860f..079aeec0d980e0f526176f01aae38951fb1db675 100644
--- a/lib/src/checker/checker.dart
+++ b/lib/src/checker/checker.dart
@@ -381,6 +381,36 @@ class CodeChecker extends RecursiveAstVisitor {
}
}
+ @override visitListLiteral(ListLiteral node) {
+ var type = _rules.provider.dynamicType;
+ if (node.typeArguments != null) {
+ var targs = node.typeArguments.arguments;
+ if (targs.length > 0) type = targs[0].type;
+ }
+ var elements = node.elements;
vsm 2015/02/25 20:52:28 You could lift this block into the nested if above
Leaf 2015/02/25 21:07:04 Yeah, had it that way, then changed it just on the
+ for (int i = 0; i < elements.length; i++) {
+ elements[i] = checkArgument(elements[i], type);
vsm 2015/02/25 20:52:29 Are you already keeping track of whether we're in
Leaf 2015/02/25 21:07:04 I'm not checking for const currently. I considere
+ }
+ super.visitListLiteral(node);
+ }
+
+ @override visitMapLiteral(MapLiteral node) {
+ var ktype = _rules.provider.dynamicType;
+ var vtype = _rules.provider.dynamicType;
+ if (node.typeArguments != null) {
+ var targs = node.typeArguments.arguments;
+ if (targs.length > 0) ktype = targs[0].type;
+ if (targs.length > 1) vtype = targs[1].type;
+ }
+ var entries = node.entries;
vsm 2015/02/25 20:52:29 ditto
+ for (int i = 0; i < entries.length; i++) {
+ var entry = entries[i];
+ entry.key = checkArgument(entry.key, ktype);
+ entry.value = checkArgument(entry.value, vtype);
+ }
+ super.visitMapLiteral(node);
+ }
+
// Check invocations
bool checkArgumentList(ArgumentList node, FunctionType type) {
NodeList<Expression> list = node.arguments;
« no previous file with comments | « no previous file | test/checker/checker_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698