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

Side by Side 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, 1 month 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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 library engine.resolver_test; 5 library engine.resolver_test;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'package:analyzer/src/context/context.dart' as newContext; 9 import 'package:analyzer/src/context/context.dart' as newContext;
10 import 'package:analyzer/src/generated/ast.dart'; 10 import 'package:analyzer/src/generated/ast.dart';
(...skipping 2340 matching lines...) Expand 10 before | Expand all | Expand 10 after
2351 m() { 2351 m() {
2352 var i = ''; 2352 var i = '';
2353 n(i); 2353 n(i);
2354 } 2354 }
2355 n(int i) {}'''); 2355 n(int i) {}''');
2356 computeLibrarySourceErrors(source); 2356 computeLibrarySourceErrors(source);
2357 assertErrors(source, [HintCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); 2357 assertErrors(source, [HintCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
2358 verify([source]); 2358 verify([source]);
2359 } 2359 }
2360 2360
2361 void test_canBeNullAfterNullAware_methodInvocation() {
2362 Source source = addSource(r'''
2363 m(x) {
2364 x?.a.b();
2365 }
2366 ''');
2367 computeLibrarySourceErrors(source);
2368 assertErrors(source, [HintCode.CAN_BE_NULL_AFTER_NULL_AWARE]);
2369 verify([source]);
2370 }
2371
2372 void test_canBeNullAfterNullAware_parenthesized() {
2373 Source source = addSource(r'''
2374 m(x) {
2375 (x?.a).b;
2376 }
2377 ''');
2378 computeLibrarySourceErrors(source);
2379 assertErrors(source, [HintCode.CAN_BE_NULL_AFTER_NULL_AWARE]);
2380 verify([source]);
2381 }
2382
2383 void test_canBeNullAfterNullAware_propertyAccess() {
2384 Source source = addSource(r'''
2385 m(x) {
2386 x?.a.b;
2387 }
2388 ''');
2389 computeLibrarySourceErrors(source);
2390 assertErrors(source, [HintCode.CAN_BE_NULL_AFTER_NULL_AWARE]);
2391 verify([source]);
2392 }
2393
2361 void test_deadCode_deadBlock_conditionalElse() { 2394 void test_deadCode_deadBlock_conditionalElse() {
2362 Source source = addSource(r''' 2395 Source source = addSource(r'''
2363 f() { 2396 f() {
2364 true ? 1 : 2; 2397 true ? 1 : 2;
2365 }'''); 2398 }''');
2366 computeLibrarySourceErrors(source); 2399 computeLibrarySourceErrors(source);
2367 assertErrors(source, [HintCode.DEAD_CODE]); 2400 assertErrors(source, [HintCode.DEAD_CODE]);
2368 verify([source]); 2401 verify([source]);
2369 } 2402 }
2370 2403
(...skipping 12658 matching lines...) Expand 10 before | Expand all | Expand 10 after
15029 15062
15030 void _resolveTestUnit(String code) { 15063 void _resolveTestUnit(String code) {
15031 testCode = code; 15064 testCode = code;
15032 testSource = addSource(testCode); 15065 testSource = addSource(testCode);
15033 LibraryElement library = resolve2(testSource); 15066 LibraryElement library = resolve2(testSource);
15034 assertNoErrors(testSource); 15067 assertNoErrors(testSource);
15035 verify([testSource]); 15068 verify([testSource]);
15036 testUnit = resolveCompilationUnit(testSource, library); 15069 testUnit = resolveCompilationUnit(testSource, library);
15037 } 15070 }
15038 } 15071 }
OLDNEW
« 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