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

Side by Side Diff: tests/language/conditional_property_access_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 does not appear on the LHS of an 5 // Verify semantics of the ?. operator when it does not appear 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 noMethod(e) => e is NoSuchMethodError; 11 noMethod(e) => e is NoSuchMethodError;
14 12
15 class B {} 13 class B {}
16 14
17 class C extends B { 15 class C extends B {
18 int v; 16 int v;
19 C(this.v); 17 C(this.v);
(...skipping 26 matching lines...) Expand all
46 Expect.throws(() => h.C?.staticField, noMethod); /// 08: static type warning 44 Expect.throws(() => h.C?.staticField, noMethod); /// 08: static type warning
47 45
48 // Nor can it be used to access toplevel properties in libraries imported via 46 // Nor can it be used to access toplevel properties in libraries imported via
49 // prefix. 47 // prefix.
50 var x = h?.topLevelVar; /// 09: compile-time error 48 var x = h?.topLevelVar; /// 09: compile-time error
51 49
52 // However, '?.' can be used to access the hashCode getter on the class Type. 50 // However, '?.' can be used to access the hashCode getter on the class Type.
53 Expect.equals(C?.hashCode, (C).hashCode); /// 10: ok 51 Expect.equals(C?.hashCode, (C).hashCode); /// 10: ok
54 Expect.equals(h.C?.hashCode, (h.C).hashCode); /// 11: ok 52 Expect.equals(h.C?.hashCode, (h.C).hashCode); /// 11: ok
55 } 53 }
OLDNEW
« no previous file with comments | « tests/language/conditional_method_invocation_test.dart ('k') | tests/language/conditional_property_assignment_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698