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

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

Issue 2078493002: Don't flag improper @protected access in docs (#26713). (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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/lib/src/generated/resolver.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/test/generated/hint_code_test.dart
diff --git a/pkg/analyzer/test/generated/hint_code_test.dart b/pkg/analyzer/test/generated/hint_code_test.dart
index bd01388937f4fdc9c8639d752120cb49ea5382d2..645ebeb93bf43ba20ae00bdfe9f7202451cfdc13 100644
--- a/pkg/analyzer/test/generated/hint_code_test.dart
+++ b/pkg/analyzer/test/generated/hint_code_test.dart
@@ -377,6 +377,49 @@ f() {
verify([source]);
}
+ void test_deadCode_deadFinalReturnInCase() {
+ Source source = addSource(r'''
+f() {
+ switch (true) {
+ case true:
+ try {
+ int a = 1;
+ } finally {
+ return;
+ }
+ return;
+ default:
+ break;
+ }
+}''');
+ computeLibrarySourceErrors(source);
+ assertErrors(source, [HintCode.DEAD_CODE]);
+ verify([source]);
+ }
+
+ void test_deadCode_deadFinalStatementInCase() {
+ Source source = addSource(r'''
+f() {
+ switch (true) {
+ case true:
+ try {
+ int a = 1;
+ } finally {
+ return;
+ }
+ int b = 1;
+ default:
+ break;
+ }
+}''');
+ computeLibrarySourceErrors(source);
+ // A single dead statement at the end of a switch case that is not a
+ // terminating statement will yield two errors.
+ assertErrors(source,
+ [HintCode.DEAD_CODE, StaticWarningCode.CASE_BLOCK_NOT_TERMINATED]);
+ verify([source]);
+ }
+
void test_deadCode_deadOperandLHS_and() {
Source source = addSource(r'''
f() {
@@ -473,49 +516,6 @@ f(v) {
verify([source]);
}
- void test_deadCode_deadFinalReturnInCase() {
- Source source = addSource(r'''
-f() {
- switch (true) {
- case true:
- try {
- int a = 1;
- } finally {
- return;
- }
- return;
- default:
- break;
- }
-}''');
- computeLibrarySourceErrors(source);
- assertErrors(source, [HintCode.DEAD_CODE]);
- verify([source]);
- }
-
- void test_deadCode_deadFinalStatementInCase() {
- Source source = addSource(r'''
-f() {
- switch (true) {
- case true:
- try {
- int a = 1;
- } finally {
- return;
- }
- int b = 1;
- default:
- break;
- }
-}''');
- computeLibrarySourceErrors(source);
- // A single dead statement at the end of a switch case that is not a
- // terminating statement will yield two errors.
- assertErrors(source,
- [HintCode.DEAD_CODE, StaticWarningCode.CASE_BLOCK_NOT_TERMINATED]);
- verify([source]);
- }
-
void test_deadCode_statementAfterBreak_inWhileStatement() {
Source source = addSource(r'''
f(v) {
@@ -1196,6 +1196,27 @@ abstract class B implements A {
verify([source]);
}
+ void test_invalidUseOfProtectedMember_in_docs_OK() {
+ Source source = addSource(r'''
+import 'package:meta/meta.dart';
+
+class A {
+ @protected
+ int a() => c;
+ @protected
+ int get b => a();
+ @protected
+ int c = 42;
+}
+
+/// OK: [A.a], [A.b], [A.c].
+f() {}
+''');
+ computeLibrarySourceErrors(source);
+ assertNoErrors(source);
+ verify([source]);
+ }
+
void test_invalidUseOfProtectedMember_message() {
Source source = addSource(r'''
import 'package:meta/meta.dart';
« 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