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

Unified Diff: pkg/analyzer/test/src/task/strong/inferred_type_test.dart

Issue 2217693003: fix #26552, improve null coalescing inference (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: add test Created 4 years, 4 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/resolver.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 fe2bdfb5b3bf259875a65f89eba2c612f3d953e7..e17448aaadf72e35cded2f56eb7584d5005ea35d 100644
--- a/pkg/analyzer/test/src/task/strong/inferred_type_test.dart
+++ b/pkg/analyzer/test/src/task/strong/inferred_type_test.dart
@@ -3626,6 +3626,23 @@ test1() {
''');
}
+ void test_nullCoalescingOperator() {
+ // Regression test for https://github.com/dart-lang/sdk/issues/26552
+ checkFile(r'''
+List<int> x;
+var y = x ?? /*info:INFERRED_TYPE_LITERAL*/[];
+List<int> z = y;
+ ''');
+ // Don't do anything if we already have a context type.
+ var unit = checkFile(r'''
+List<int> x;
+List<num> y = x ?? /*info:INFERRED_TYPE_LITERAL*/[];
+ ''');
+
+ expect(unit.topLevelVariables[1].initializer.returnType.toString(),
+ 'List<num>');
+ }
+
void test_nullLiteralShouldNotInferAsBottom() {
// Regression test for https://github.com/dart-lang/dev_compiler/issues/47
checkFile(r'''
« no previous file with comments | « pkg/analyzer/lib/src/generated/resolver.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698