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

Unified Diff: pkg/analyzer/test/src/task/strong/inferred_type_test.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 | « pkg/analyzer/lib/src/generated/static_type_analyzer.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/test/src/task/strong/inferred_type_test.dart
diff --git a/pkg/analyzer/test/src/task/strong/inferred_type_test.dart b/pkg/analyzer/test/src/task/strong/inferred_type_test.dart
index 4bfe3521a8803f99d121454fab54fa781178e367..7f80ef3dd2c97de5b519581b00e0bd87393c9472 100644
--- a/pkg/analyzer/test/src/task/strong/inferred_type_test.dart
+++ b/pkg/analyzer/test/src/task/strong/inferred_type_test.dart
@@ -1939,6 +1939,17 @@ test2() {
''');
});
+ test('list literals should not infer bottom', () {
+ var unit = checkFile(r'''
+test1() {
+ var x = [null];
+ x.add(42);
+}
+ ''');
+ var x = unit.element.functions[0].localVariables[0];
+ expect(x.type.toString(), 'List<dynamic>');
+ });
+
test('map literals', () {
checkFile(r'''
test1() {
@@ -1963,6 +1974,17 @@ test2() {
''');
});
+ test('map literals should not infer bottom', () {
+ var unit = checkFile(r'''
+test1() {
+ var x = { null: null };
+ x[3] = 'z';
+}
+
+ ''');
+ var x = unit.element.functions[0].localVariables[0];
+ expect(x.type.toString(), 'Map<dynamic, dynamic>');
+ });
group('block bodied lambdas', () {
// Original feature request: https://github.com/dart-lang/sdk/issues/25487
« no previous file with comments | « pkg/analyzer/lib/src/generated/static_type_analyzer.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698