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

Side by Side Diff: pkg/analyzer/test/generated/hint_code_test.dart

Issue 2041873003: Fix @protected to include closure references (linter#255). (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 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
« no previous file with comments | « pkg/analyzer/lib/src/generated/resolver.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 analyzer.test.generated.hint_code_test; 5 library analyzer.test.generated.hint_code_test;
6 6
7 import 'package:analyzer/src/generated/engine.dart'; 7 import 'package:analyzer/src/generated/engine.dart';
8 import 'package:analyzer/src/generated/error.dart'; 8 import 'package:analyzer/src/generated/error.dart';
9 import 'package:analyzer/src/generated/source_io.dart'; 9 import 'package:analyzer/src/generated/source_io.dart';
10 import 'package:unittest/unittest.dart'; 10 import 'package:unittest/unittest.dart';
(...skipping 1087 matching lines...) Expand 10 before | Expand all | Expand 10 after
1098 } 1098 }
1099 1099
1100 abstract class B implements A { 1100 abstract class B implements A {
1101 int b() => a(); 1101 int b() => a();
1102 }'''); 1102 }''');
1103 computeLibrarySourceErrors(source); 1103 computeLibrarySourceErrors(source);
1104 assertNoErrors(source); 1104 assertNoErrors(source);
1105 verify([source]); 1105 verify([source]);
1106 } 1106 }
1107 1107
1108 void test_invalidUseOfProtectedMember_closure() {
1109 Source source = addSource(r'''
1110 import 'package:meta/meta.dart';
1111
1112 class A {
1113 @protected
1114 int a() => 42;
1115 }
1116 void main() {
1117 var leak = new A().a;
1118 print(leak);
1119 }''');
1120 computeLibrarySourceErrors(source);
1121 assertErrors(source, [HintCode.INVALID_USE_OF_PROTECTED_MEMBER]);
1122 verify([source]);
1123 }
1124
1108 void test_invalidUseOfProtectedMember_getter() { 1125 void test_invalidUseOfProtectedMember_getter() {
1109 Source source = addSource(r''' 1126 Source source = addSource(r'''
1110 import 'package:meta/meta.dart'; 1127 import 'package:meta/meta.dart';
1111 class A { 1128 class A {
1112 @protected 1129 @protected
1113 int get a => 42; 1130 int get a => 42;
1114 } 1131 }
1115 class B { 1132 class B {
1116 A a; 1133 A a;
1117 int b() => a.a; 1134 int b() => a.a;
(...skipping 2343 matching lines...) Expand 10 before | Expand all | Expand 10 after
3461 n() { 3478 n() {
3462 var a = m(), b = m(); 3479 var a = m(), b = m();
3463 } 3480 }
3464 }'''); 3481 }''');
3465 computeLibrarySourceErrors(source); 3482 computeLibrarySourceErrors(source);
3466 assertErrors( 3483 assertErrors(
3467 source, [HintCode.USE_OF_VOID_RESULT, HintCode.USE_OF_VOID_RESULT]); 3484 source, [HintCode.USE_OF_VOID_RESULT, HintCode.USE_OF_VOID_RESULT]);
3468 verify([source]); 3485 verify([source]);
3469 } 3486 }
3470 } 3487 }
OLDNEW
« no previous file with comments | « 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