| OLD | NEW |
| 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 Loading... |
| 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 } |
| OLD | NEW |