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

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

Issue 1759363002: Fixes list/map literal to not infer bottom (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 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 | pkg/analyzer/test/src/task/strong/inferred_type_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/static_type_analyzer.dart
diff --git a/pkg/analyzer/lib/src/generated/static_type_analyzer.dart b/pkg/analyzer/lib/src/generated/static_type_analyzer.dart
index 86ce8301533440ca7045760c2413f134f912392b..12c9aac90526d7bcebf62e9e4836f66603e720c4 100644
--- a/pkg/analyzer/lib/src/generated/static_type_analyzer.dart
+++ b/pkg/analyzer/lib/src/generated/static_type_analyzer.dart
@@ -635,9 +635,12 @@ class StaticTypeAnalyzer extends SimpleAstVisitor<Object> {
_resolver.inferenceContext.recordInference(node, contextType);
} else if (node.elements.isNotEmpty) {
// Infer the list type from the arguments.
+ // TODO(jmesserly): record inference here?
staticType =
node.elements.map((e) => e.staticType).reduce(_leastUpperBound);
- // TODO(jmesserly): record inference here?
+ if (staticType.isBottom) {
+ staticType = _dynamicType;
+ }
}
}
_recordStaticType(
@@ -686,12 +689,18 @@ class StaticTypeAnalyzer extends SimpleAstVisitor<Object> {
_resolver.inferenceContext.recordInference(node, contextType);
} else if (node.entries.isNotEmpty) {
// Infer the list type from the arguments.
+ // TODO(jmesserly): record inference here?
staticKeyType =
node.entries.map((e) => e.key.staticType).reduce(_leastUpperBound);
staticValueType = node.entries
.map((e) => e.value.staticType)
.reduce(_leastUpperBound);
- // TODO(jmesserly): record inference here?
+ if (staticKeyType.isBottom) {
+ staticKeyType = _dynamicType;
+ }
+ if (staticValueType.isBottom) {
+ staticValueType = _dynamicType;
+ }
}
}
_recordStaticType(
« no previous file with comments | « no previous file | pkg/analyzer/test/src/task/strong/inferred_type_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698