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

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

Issue 1173523002: Fix analyzer's handling of import prefixes not followed by '.'. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 6 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 8 // SharedOptions=--enable-null-aware-operators
9 9
10 import "package:expect/expect.dart"; 10 import "package:expect/expect.dart";
(...skipping 29 matching lines...) Expand all
40 // generated in the case of e1?.id. 40 // generated in the case of e1?.id.
41 Expect.equals(null, nullC()?.bad); /// 05: static type warning 41 Expect.equals(null, nullC()?.bad); /// 05: static type warning
42 { B b = new C(1); Expect.equals(1, b?.v); } /// 06: static type warning 42 { B b = new C(1); Expect.equals(1, b?.v); } /// 06: static type warning
43 43
44 // Consequently, '?.' cannot be used to access static properties of classes. 44 // Consequently, '?.' cannot be used to access static properties of classes.
45 Expect.throws(() => C?.staticField, noMethod); /// 07: static type warning 45 Expect.throws(() => C?.staticField, noMethod); /// 07: static type warning
46 Expect.throws(() => h.C?.staticField, noMethod); /// 08: static type warning 46 Expect.throws(() => h.C?.staticField, noMethod); /// 08: static type warning
47 47
48 // Nor can it be used to access toplevel properties in libraries imported via 48 // Nor can it be used to access toplevel properties in libraries imported via
49 // prefix. 49 // prefix.
50 Expect.throws(() => h?.topLevelVar, noMethod); /// 09: static type warning 50 var x = h?.topLevelVar; /// 09: compile-time error
51 51
52 // However, '?.' can be used to access the hashCode getter on the class Type. 52 // However, '?.' can be used to access the hashCode getter on the class Type.
53 Expect.equals(C?.hashCode, (C).hashCode); /// 10: ok 53 Expect.equals(C?.hashCode, (C).hashCode); /// 10: ok
54 Expect.equals(h.C?.hashCode, (h.C).hashCode); /// 11: ok 54 Expect.equals(h.C?.hashCode, (h.C).hashCode); /// 11: ok
55 } 55 }
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