Index: dart/sdk/lib/_internal/compiler/implementation/inferrer/type_graph_nodes.dart |
=================================================================== |
--- dart/sdk/lib/_internal/compiler/implementation/inferrer/type_graph_nodes.dart (revision 37347) |
+++ dart/sdk/lib/_internal/compiler/implementation/inferrer/type_graph_nodes.dart (working copy) |
@@ -1059,8 +1059,10 @@ |
bool analyzed = false; |
// Set to false if a statically unknown key flows into this map. |
- bool isDictionary = true; |
+ bool _allKeysAreStrings = true; |
+ bool get inDictionaryMode => !bailedOut && _allKeysAreStrings; |
+ |
MapTypeInformation(this.initialType, this.keyType, this.valueType) { |
keyType.addUser(this); |
valueType.addUser(this); |
@@ -1071,13 +1073,13 @@ |
TypeInformation value, |
[bool nonNull = false]) { |
TypeInformation newInfo = null; |
- if (isDictionary && key is StringLiteralTypeInformation) { |
+ if (_allKeysAreStrings && key is StringLiteralTypeInformation) { |
String keyString = key.asString(); |
typeInfoMap.putIfAbsent(keyString, |
() => newInfo = new ValueInMapTypeInformation(null, nonNull)); |
typeInfoMap[keyString].addAssignment(value); |
} else { |
- isDictionary = false; |
+ _allKeysAreStrings = false; |
typeInfoMap.clear(); |
} |
keyType.addAssignment(key); |
@@ -1087,10 +1089,10 @@ |
return newInfo; |
} |
- List<TypeInformation> addMapAssignment(MapTypeInformation map) { |
+ List<TypeInformation> addMapAssignment(MapTypeInformation other) { |
List<TypeInformation> newInfos = <TypeInformation>[]; |
- if (map.isDictionary) { |
- map.typeInfoMap.forEach((keyString, value) { |
+ if (_allKeysAreStrings && other.inDictionaryMode) { |
+ other.typeInfoMap.forEach((keyString, value) { |
typeInfoMap.putIfAbsent(keyString, () { |
TypeInformation newInfo = new ValueInMapTypeInformation(null, false); |
newInfos.add(newInfo); |
@@ -1098,9 +1100,12 @@ |
}); |
typeInfoMap[keyString].addAssignment(value); |
}); |
+ } else { |
+ _allKeysAreStrings = false; |
+ typeInfoMap.clear(); |
} |
- keyType.addAssignment(map.keyType); |
- valueType.addAssignment(map.valueType); |
+ keyType.addAssignment(other.keyType); |
+ valueType.addAssignment(other.valueType); |
return newInfos; |
} |
@@ -1119,7 +1124,7 @@ |
} |
TypeMask toTypeMask(TypeGraphInferrerEngine inferrer) { |
- if (isDictionary) { |
+ if (inDictionaryMode) { |
Map<String, TypeMask> mappings = new Map<String, TypeMask>(); |
for (var key in typeInfoMap.keys) { |
mappings[key] = typeInfoMap[key].type; |
@@ -1140,9 +1145,10 @@ |
} |
TypeMask refine(TypeGraphInferrerEngine inferrer) { |
- if (!bailedOut && type.isDictionary != isDictionary) { |
+ if (type.isDictionary != inDictionaryMode) { |
return toTypeMask(inferrer); |
- } else if (!bailedOut && type.isDictionary) { |
+ } else if (type.isDictionary) { |
+ assert(inDictionaryMode); |
DictionaryTypeMask mask = type; |
for (var key in typeInfoMap.keys) { |
TypeInformation value = typeInfoMap[key]; |