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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 // 4 //
5 // VMOptions=--optimization_counter_threshold=5 5 // VMOptions=--optimization_counter_threshold=5
6 // 6 //
7 // Basic null-aware operator test that invokes the optimizing compiler. 7 // Basic null-aware operator test that invokes the optimizing compiler.
8 8
9 import "package:expect/expect.dart"; 9 import "package:expect/expect.dart";
10 10
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 String s; 72 String s;
73 } 73 }
74 74
75 class Foo { 75 class Foo {
76 Bar _bar; 76 Bar _bar;
77 String str; 77 String str;
78 78
79 Foo(this._bar) : str = _bar?.s; 79 Foo(this._bar) : str = _bar?.s;
80 } 80 }
81 81
82 // Check that ?? isn't incorrectly optimized as non-nullable
83 // (DDC regression test)
84 test3() {
85 List n = null;
86 var func = n?.add;
87 var result = func ?? 1;
88 Expect.equals(result, 1);
89 }
90
82 main() { 91 main() {
83 for (int i = 0; i < 10; i++) { 92 for (int i = 0; i < 10; i++) {
84 test(); 93 test();
85 test2(); 94 test2();
95 test3();
86 } 96 }
87 97
88 Expect.equals(null, new Foo(new Bar()).str); 98 Expect.equals(null, new Foo(new Bar()).str);
89 } 99 }
OLDNEW
« 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