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

Unified Diff: pkg/analyzer/lib/src/generated/constant.dart

Issue 641413002: Substitute type parameters when evaluating const literal maps/lists. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 2 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 | pkg/analyzer/test/generated/resolver_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/generated/constant.dart
diff --git a/pkg/analyzer/lib/src/generated/constant.dart b/pkg/analyzer/lib/src/generated/constant.dart
index 419034b05c98d3b57a162d9f96622671eae3a75c..0f7d0cdc3e3d07df89fb64f12f2731129e3ee0c4 100644
--- a/pkg/analyzer/lib/src/generated/constant.dart
+++ b/pkg/analyzer/lib/src/generated/constant.dart
@@ -1127,7 +1127,15 @@ class ConstantVisitor extends UnifyingAstVisitor<DartObjectImpl> {
if (errorOccurred) {
return null;
}
- return new DartObjectImpl(_typeProvider.listType, new ListState(new List.from(elements)));
+ DartType elementType = _typeProvider.dynamicType;
+ if (node.typeArguments != null && node.typeArguments.arguments.length == 1) {
+ DartType type = node.typeArguments.arguments[0].type;
+ if (type != null) {
+ elementType = type;
+ }
+ }
+ InterfaceType listType = _typeProvider.listType.substitute4([elementType]);
+ return new DartObjectImpl(listType, new ListState(new List.from(elements)));
}
@override
@@ -1150,7 +1158,21 @@ class ConstantVisitor extends UnifyingAstVisitor<DartObjectImpl> {
if (errorOccurred) {
return null;
}
- return new DartObjectImpl(_typeProvider.mapType, new MapState(map));
+ DartType keyType = _typeProvider.dynamicType;
+ DartType valueType = _typeProvider.dynamicType;
+ if (node.typeArguments != null && node.typeArguments.arguments.length == 2) {
+ DartType keyTypeCandidate = node.typeArguments.arguments[0].type;
+ if (keyTypeCandidate != null) {
+ keyType = keyTypeCandidate;
+ }
+ DartType valueTypeCandidate = node.typeArguments.arguments[1].type;
+ if (valueTypeCandidate != null) {
+ valueType = valueTypeCandidate;
+ }
+ }
+ InterfaceType mapType = _typeProvider.mapType.substitute4(
+ [keyType, valueType]);
+ return new DartObjectImpl(mapType, new MapState(map));
}
@override
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/resolver_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698