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

Unified Diff: tests/language_strong/nullaware_opt_test.dart

Issue 2996523003: Fix incorrect nullability inference for ?? (Closed)
Patch Set: Created 3 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/dev_compiler/lib/src/compiler/nullable_type_inference.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/language_strong/nullaware_opt_test.dart
diff --git a/tests/language_strong/nullaware_opt_test.dart b/tests/language_strong/nullaware_opt_test.dart
index 0436e8b2aac64106d1412e233176264a36566ad2..017ae4c433cef6885a5e7101a427f24e81779e98 100644
--- a/tests/language_strong/nullaware_opt_test.dart
+++ b/tests/language_strong/nullaware_opt_test.dart
@@ -79,10 +79,20 @@ class Foo {
Foo(this._bar) : str = _bar?.s;
}
+// Check that ?? isn't incorrectly optimized as non-nullable
+// (DDC regression test)
+test3() {
+ List n = null;
+ var func = n?.add;
+ var result = func ?? 1;
+ Expect.equals(result, 1);
+}
+
main() {
for (int i = 0; i < 10; i++) {
test();
test2();
+ test3();
}
Expect.equals(null, new Foo(new Bar()).str);
« no previous file with comments | « pkg/dev_compiler/lib/src/compiler/nullable_type_inference.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698