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

Unified Diff: pkg/analyzer/test/generated/resolver_test.dart

Issue 1423623005: Report hint when target of an invocation uses '?.', so can be null. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: pkg/analyzer/test/generated/resolver_test.dart
diff --git a/pkg/analyzer/test/generated/resolver_test.dart b/pkg/analyzer/test/generated/resolver_test.dart
index 6ed5d4cb199d9d63b6540c727561df51c7ecb80a..590affc97374d1090d30fc04bed1baa267947b26 100644
--- a/pkg/analyzer/test/generated/resolver_test.dart
+++ b/pkg/analyzer/test/generated/resolver_test.dart
@@ -2358,6 +2358,39 @@ n(int i) {}''');
verify([source]);
}
+ void test_canBeNullAfterNullAware_methodInvocation() {
+ Source source = addSource(r'''
+m(x) {
+ x?.a.b();
+}
+''');
+ computeLibrarySourceErrors(source);
+ assertErrors(source, [HintCode.CAN_BE_NULL_AFTER_NULL_AWARE]);
+ verify([source]);
+ }
+
+ void test_canBeNullAfterNullAware_parenthesized() {
+ Source source = addSource(r'''
+m(x) {
+ (x?.a).b;
+}
+''');
+ computeLibrarySourceErrors(source);
+ assertErrors(source, [HintCode.CAN_BE_NULL_AFTER_NULL_AWARE]);
+ verify([source]);
+ }
+
+ void test_canBeNullAfterNullAware_propertyAccess() {
+ Source source = addSource(r'''
+m(x) {
+ x?.a.b;
+}
+''');
+ computeLibrarySourceErrors(source);
+ assertErrors(source, [HintCode.CAN_BE_NULL_AFTER_NULL_AWARE]);
+ verify([source]);
+ }
+
void test_deadCode_deadBlock_conditionalElse() {
Source source = addSource(r'''
f() {
« pkg/analyzer/lib/src/generated/resolver.dart ('K') | « pkg/analyzer/lib/src/generated/resolver.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698