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

Side by Side Diff: tests/language/conditional_property_assignment_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 semantics of the ?. operator when it appears on the LHS of an 5 // Verify semantics of the ?. operator when it appears on the LHS of an
6 // assignment. 6 // assignment.
7 7
8 // SharedOptions=--enable-null-aware-operators
9
10 import "package:expect/expect.dart"; 8 import "package:expect/expect.dart";
11 import "conditional_access_helper.dart" as h; 9 import "conditional_access_helper.dart" as h;
12 10
13 bad() { 11 bad() {
14 Expect.fail('Should not be executed'); 12 Expect.fail('Should not be executed');
15 } 13 }
16 14
17 noMethod(e) => e is NoSuchMethodError; 15 noMethod(e) => e is NoSuchMethodError;
18 16
19 class B {} 17 class B {}
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 Expect.throws(() => h.C?.staticField = null, noMethod); /// 17: static type wa rning 82 Expect.throws(() => h.C?.staticField = null, noMethod); /// 17: static type wa rning
85 Expect.throws(() => h.C?.staticField += null, noMethod); /// 18: static type w arning 83 Expect.throws(() => h.C?.staticField += null, noMethod); /// 18: static type w arning
86 Expect.throws(() => h.C?.staticField ??= null, noMethod); /// 19: static type warning 84 Expect.throws(() => h.C?.staticField ??= null, noMethod); /// 19: static type warning
87 85
88 // Nor can it be used to assign to toplevel properties in libraries imported 86 // Nor can it be used to assign to toplevel properties in libraries imported
89 // via prefix. 87 // via prefix.
90 h?.topLevelVar = null; /// 20: compile-time error 88 h?.topLevelVar = null; /// 20: compile-time error
91 h?.topLevelVar += null; /// 21: compile-time error 89 h?.topLevelVar += null; /// 21: compile-time error
92 h?.topLevelVar ??= null; /// 22: compile-time error 90 h?.topLevelVar ??= null; /// 22: compile-time error
93 } 91 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698