Index: pkg/analyzer/lib/src/generated/resolver.dart |
diff --git a/pkg/analyzer/lib/src/generated/resolver.dart b/pkg/analyzer/lib/src/generated/resolver.dart |
index 796b216ceffa3de3c87ebb3f88f3d25e1ea23bc7..e84e9ce994377f58f2be3ad6ece158aec8c155c2 100644 |
--- a/pkg/analyzer/lib/src/generated/resolver.dart |
+++ b/pkg/analyzer/lib/src/generated/resolver.dart |
@@ -11747,22 +11747,25 @@ class ResolverVisitor extends ScopedVisitor { |
@override |
Object visitListLiteral(ListLiteral node) { |
DartType contextType = InferenceContext.getType(node); |
- if (node.typeArguments == null && contextType is InterfaceType) { |
+ List<DartType> targs = null; |
+ if (node.typeArguments != null) { |
+ targs = node.typeArguments.arguments.map((t) => t.type).toList(); |
+ } else if (contextType is InterfaceType) { |
InterfaceType listD = |
typeProvider.listType.substitute4([typeProvider.dynamicType]); |
- List<DartType> targs = inferenceContext.matchTypes(listD, contextType); |
- if (targs != null && |
- targs.length == 1 && |
- targs.any((t) => !t.isDynamic)) { |
- DartType eType = targs[0]; |
- InterfaceType listT = typeProvider.listType.substitute4([eType]); |
- for (Expression child in node.elements) { |
- InferenceContext.setType(child, eType); |
- } |
- InferenceContext.setType(node, listT); |
- } else { |
- InferenceContext.clearType(node); |
+ targs = inferenceContext.matchTypes(listD, contextType); |
+ } |
+ if (targs != null && |
+ targs.length == 1 && |
+ !targs[0].isDynamic) { |
+ DartType eType = targs[0]; |
+ InterfaceType listT = typeProvider.listType.substitute4([eType]); |
+ for (Expression child in node.elements) { |
+ InferenceContext.setType(child, eType); |
} |
+ InferenceContext.setType(node, listT); |
+ } else { |
+ InferenceContext.clearType(node); |
} |
super.visitListLiteral(node); |
return null; |
@@ -11771,24 +11774,27 @@ class ResolverVisitor extends ScopedVisitor { |
@override |
Object visitMapLiteral(MapLiteral node) { |
DartType contextType = InferenceContext.getType(node); |
- if (node.typeArguments == null && contextType is InterfaceType) { |
+ List<DartType> targs = null; |
+ if (node.typeArguments != null) { |
+ targs = node.typeArguments.arguments.map((t) => t.type).toList(); |
+ } else if (contextType is InterfaceType) { |
InterfaceType mapD = typeProvider.mapType |
.substitute4([typeProvider.dynamicType, typeProvider.dynamicType]); |
- List<DartType> targs = inferenceContext.matchTypes(mapD, contextType); |
- if (targs != null && |
- targs.length == 2 && |
- targs.any((t) => !t.isDynamic)) { |
- DartType kType = targs[0]; |
- DartType vType = targs[1]; |
- InterfaceType mapT = typeProvider.mapType.substitute4([kType, vType]); |
- for (MapLiteralEntry entry in node.entries) { |
- InferenceContext.setType(entry.key, kType); |
- InferenceContext.setType(entry.value, vType); |
- } |
- InferenceContext.setType(node, mapT); |
- } else { |
- InferenceContext.clearType(node); |
- } |
+ targs = inferenceContext.matchTypes(mapD, contextType); |
+ } |
+ if (targs != null && |
+ targs.length == 2 && |
+ targs.any((t) => !t.isDynamic)) { |
+ DartType kType = targs[0]; |
+ DartType vType = targs[1]; |
+ InterfaceType mapT = typeProvider.mapType.substitute4([kType, vType]); |
+ for (MapLiteralEntry entry in node.entries) { |
+ InferenceContext.setType(entry.key, kType); |
+ InferenceContext.setType(entry.value, vType); |
+ } |
+ InferenceContext.setType(node, mapT); |
+ } else { |
+ InferenceContext.clearType(node); |
} |
super.visitMapLiteral(node); |
return null; |