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

Side by Side Diff: tests/language/if_null_assignment_static_test.dart

Issue 1239513005: Switch on null-aware operators by default in analyzer. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 5 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
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 // Verify that the static type of a ??= b is the least upper bound of the 5 // Verify that the static type of a ??= b is the least upper bound of the
6 // static types of a and b. 6 // static types of a and b.
7 7
8 // SharedOptions=--enable-null-aware-operators
9
10 import "package:expect/expect.dart"; 8 import "package:expect/expect.dart";
11 9
12 // Determine whether the VM is running in checked mode. 10 // Determine whether the VM is running in checked mode.
13 bool get checkedMode { 11 bool get checkedMode {
14 try { 12 try {
15 var x = 'foo'; 13 var x = 'foo';
16 int y = x; 14 int y = x;
17 return false; 15 return false;
18 } catch (_) { 16 } catch (_) {
19 return true; 17 return true;
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 (new ClassWithInstanceGetters()?.a ??= new B()).b; /// 39: static type warning 165 (new ClassWithInstanceGetters()?.a ??= new B()).b; /// 39: static type warning
168 if (!checkedMode) { 166 if (!checkedMode) {
169 (new ClassWithInstanceGetters()?.b ??= new A()).a; /// 40: ok 167 (new ClassWithInstanceGetters()?.b ??= new A()).a; /// 40: ok
170 Expect.throws(() => (new ClassWithInstanceGetters()?.b ??= new A()).b, noMet hod); /// 41: static type warning 168 Expect.throws(() => (new ClassWithInstanceGetters()?.b ??= new A()).b, noMet hod); /// 41: static type warning
171 169
172 // Exactly the same static warnings that would be caused by e1.v ??= e2 are 170 // Exactly the same static warnings that would be caused by e1.v ??= e2 are
173 // also generated in the case of e1?.v ??= e2. 171 // also generated in the case of e1?.v ??= e2.
174 new ClassWithInstanceGetters()?.b ??= new C(); /// 42: static type warning 172 new ClassWithInstanceGetters()?.b ??= new C(); /// 42: static type warning
175 } 173 }
176 } 174 }
OLDNEW
« no previous file with comments | « tests/language/if_null_assignment_behavior_test.dart ('k') | tests/language/if_null_behavior_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698