[analyzer] Add warnings to test expectations rather than ignoring.

Konstantin pointed out in
https://dart-review.googlesource.com/c/sdk/+/413521/comment/773e5821_595e0362/
that:

- The cost of including these warnings in test expectations is low,

- Including them has the advantage of including more information in
  the test, which is nice, and

- These warnings aren't really a distraction; they are an expected
  part of the analyzer's behavior (e.g., when calling a method on
  `Never`, we expect a dead code warning, even if the test in question
  is ostensibly testing some other behavior). Including the warning as
  an expected outcome has the advantage of confirming that the test is
  indeed behaving in the way we expect.

Change-Id: Iaa44e80e5332b83d5165e8a362a97dd871d8bf25
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/413561
Auto-Submit: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
diff --git a/pkg/analyzer/test/src/dart/resolution/extension_method_test.dart b/pkg/analyzer/test/src/dart/resolution/extension_method_test.dart
index 3f38ebc..761fa7c 100644
--- a/pkg/analyzer/test/src/dart/resolution/extension_method_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/extension_method_test.dart
@@ -1038,16 +1038,17 @@
   }
 
   test_instance_getter_fromInstance_Never() async {
-    await assertNoErrorsInCode('''
+    await assertErrorsInCode('''
 extension E on Never {
   int get foo => 0;
 }
 
 f(Never a) {
-  // ignore: dead_code
   a.foo;
 }
-''');
+''', [
+      error(WarningCode.DEAD_CODE, 63, 4),
+    ]);
     var access = findNode.prefixed('a.foo');
     assertResolvedNodeText(access, r'''
 PrefixedIdentifier
diff --git a/pkg/analyzer/test/src/diagnostics/dead_code_test.dart b/pkg/analyzer/test/src/diagnostics/dead_code_test.dart
index 8840364..872cf69 100644
--- a/pkg/analyzer/test/src/diagnostics/dead_code_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/dead_code_test.dart
@@ -171,10 +171,10 @@
     await assertErrorsInCode(r'''
 Never doNotReturn() => throw 0;
 
-// ignore: unnecessary_type_check_true
 test() => doNotReturn() is int;
 ''', [
-      error(WarningCode.DEAD_CODE, 99, 4),
+      error(WarningCode.UNNECESSARY_TYPE_CHECK_TRUE, 43, 20),
+      error(WarningCode.DEAD_CODE, 60, 4),
     ]);
   }
 
diff --git a/pkg/analyzer/test/src/diagnostics/receiver_of_type_never_test.dart b/pkg/analyzer/test/src/diagnostics/receiver_of_type_never_test.dart
index 8f95f61..4c5640f 100644
--- a/pkg/analyzer/test/src/diagnostics/receiver_of_type_never_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/receiver_of_type_never_test.dart
@@ -887,12 +887,13 @@
   }
 
   test_propertyAccess_never_read() async {
-    await assertNoErrorsInCode(r'''
+    await assertErrorsInCode(r'''
 void f(Never x) {
-  // ignore: dead_code
   x.foo;
 }
-''');
+''', [
+      error(WarningCode.DEAD_CODE, 22, 4),
+    ]);
 
     var node = findNode.singlePrefixedIdentifier;
     assertResolvedNodeText(node, r'''
@@ -915,12 +916,13 @@
   }
 
   test_propertyAccess_never_read_hashCode() async {
-    await assertNoErrorsInCode(r'''
+    await assertErrorsInCode(r'''
 void f(Never x) {
-  // ignore: dead_code
   x.hashCode;
 }
-''');
+''', [
+      error(WarningCode.DEAD_CODE, 22, 9),
+    ]);
 
     var node = findNode.singlePrefixedIdentifier;
     assertResolvedNodeText(node, r'''
@@ -987,12 +989,13 @@
   }
 
   test_propertyAccess_never_tearOff_toString() async {
-    await assertNoErrorsInCode(r'''
+    await assertErrorsInCode(r'''
 void f(Never x) {
-  // ignore: dead_code
   x.toString;
 }
-''');
+''', [
+      error(WarningCode.DEAD_CODE, 22, 9),
+    ]);
 
     var node = findNode.singlePrefixedIdentifier;
     assertResolvedNodeText(node, r'''
@@ -1143,12 +1146,13 @@
   }
 
   test_propertyAccess_toString() async {
-    await assertNoErrorsInCode(r'''
+    await assertErrorsInCode(r'''
 void f() {
-  // ignore: dead_code
   (throw '').toString;
 }
-''');
+''', [
+      error(WarningCode.DEAD_CODE, 24, 9),
+    ]);
 
     var node = findNode.singlePropertyAccess;
     assertResolvedNodeText(node, r'''
@@ -1173,12 +1177,13 @@
   }
 
   test_throw_getter_hashCode() async {
-    await assertNoErrorsInCode(r'''
+    await assertErrorsInCode(r'''
 void f() {
-  // ignore: dead_code
   (throw '').hashCode;
 }
-''');
+''', [
+      error(WarningCode.DEAD_CODE, 24, 9),
+    ]);
 
     var node = findNode.singlePropertyAccess;
     assertResolvedNodeText(node, r'''