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

Side by Side Diff: tests/language/conditional_method_invocation_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 is used to invoke a method. 5 // Verify semantics of the ?. operator when it is used to invoke a method.
6 6
7 // SharedOptions=--enable-null-aware-operators 7 // SharedOptions=--enable-null-aware-operators
8 8
9 import "package:expect/expect.dart"; 9 import "package:expect/expect.dart";
10 import "conditional_access_helper.dart" as h; 10 import "conditional_access_helper.dart" as h;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 // generated in the case of o?.m(...). 46 // generated in the case of o?.m(...).
47 { B b = new C(); Expect.equals(1, b?.f(() => 1)); } /// 07: static type warnin g 47 { B b = new C(); Expect.equals(1, b?.f(() => 1)); } /// 07: static type warnin g
48 { int i = 1; Expect.equals(null, nullC()?.f(i)); } /// 08: static type warning 48 { int i = 1; Expect.equals(null, nullC()?.f(i)); } /// 08: static type warning
49 49
50 // Consequently, '?.' cannot be used to invoke static methods of classes. 50 // Consequently, '?.' cannot be used to invoke static methods of classes.
51 Expect.throws(() => C?.staticMethod(), noMethod); /// 09: static type warning 51 Expect.throws(() => C?.staticMethod(), noMethod); /// 09: static type warning
52 Expect.throws(() => h.C?.staticMethod(), noMethod); /// 10: static type warnin g 52 Expect.throws(() => h.C?.staticMethod(), noMethod); /// 10: static type warnin g
53 53
54 // Nor can it be used to access toplevel functions in libraries imported via 54 // Nor can it be used to access toplevel functions in libraries imported via
55 // prefix. 55 // prefix.
56 Expect.throws(() => h?.topLevelFunction(), noMethod); /// 11: static type warn ing 56 h?.topLevelFunction(); /// 11: compile-time error
57 57
58 // However, '?.' can be used to access the toString method on the class Type. 58 // However, '?.' can be used to access the toString method on the class Type.
59 Expect.equals(C?.toString(), (C).toString()); /// 12: ok 59 Expect.equals(C?.toString(), (C).toString()); /// 12: ok
60 Expect.equals(h.C?.toString(), (h.C).toString()); /// 13: ok 60 Expect.equals(h.C?.toString(), (h.C).toString()); /// 13: ok
61 } 61 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/generated/static_warning_code_test.dart ('k') | tests/language/conditional_property_access_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698