Split out several more hint tests

Change-Id: I6483656ca2ac9c7cfa00249cf37ccbb78758ffb6
Reviewed-on: https://dart-review.googlesource.com/c/92533
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
diff --git a/pkg/analyzer/test/generated/hint_code_test.dart b/pkg/analyzer/test/generated/hint_code_test.dart
index 7f1d918..6695ba9 100644
--- a/pkg/analyzer/test/generated/hint_code_test.dart
+++ b/pkg/analyzer/test/generated/hint_code_test.dart
@@ -2,14 +2,12 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-import 'package:analyzer/dart/ast/ast.dart';
 import 'package:analyzer/error/error.dart';
 import 'package:analyzer/src/error/codes.dart';
 import 'package:analyzer/src/generated/engine.dart';
 import 'package:analyzer/src/generated/parser.dart';
 import 'package:analyzer/src/generated/source.dart';
 import 'package:analyzer/src/task/options.dart';
-import 'package:test/test.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
 import '../src/util/yaml_test.dart';
@@ -3120,1800 +3118,4 @@
     assertErrors(source, [StrongModeCode.DOWN_CAST_COMPOSITE]);
     verify([source]);
   }
-
-  test_strongMode_topLevelInstanceGetter() async {
-    Source source = addSource('''
-class A {
-  int get g => 0;
-}
-var b = new A().g;
-''');
-    var analysisResult = await computeAnalysisResult(source);
-    assertNoErrors(source);
-    TopLevelVariableDeclaration b = analysisResult.unit.declarations[1];
-    expect(b.variables.variables[0].declaredElement.type.toString(), 'int');
-    verify([source]);
-  }
-
-  test_strongMode_topLevelInstanceGetter_call() async {
-    Source source = addSource('''
-class A {
-  int Function() get g => () => 0;
-}
-var a = new A();
-var b = a.g();
-''');
-    var analysisResult = await computeAnalysisResult(source);
-    assertNoErrors(source);
-    TopLevelVariableDeclaration b = analysisResult.unit.declarations[2];
-    expect(b.variables.variables[0].declaredElement.type.toString(), 'int');
-    verify([source]);
-  }
-
-  test_strongMode_topLevelInstanceGetter_field() async {
-    Source source = addSource('''
-class A {
-  int g;
-}
-var b = new A().g;
-''');
-    var analysisResult = await computeAnalysisResult(source);
-    assertNoErrors(source);
-    TopLevelVariableDeclaration b = analysisResult.unit.declarations[1];
-    expect(b.variables.variables[0].declaredElement.type.toString(), 'int');
-    verify([source]);
-  }
-
-  test_strongMode_topLevelInstanceGetter_field_call() async {
-    Source source = addSource('''
-class A {
-  int Function() g;
-}
-var a = new A();
-var b = a.g();
-''');
-    var analysisResult = await computeAnalysisResult(source);
-    assertNoErrors(source);
-    TopLevelVariableDeclaration b = analysisResult.unit.declarations[2];
-    expect(b.variables.variables[0].declaredElement.type.toString(), 'int');
-    verify([source]);
-  }
-
-  test_strongMode_topLevelInstanceGetter_field_prefixedIdentifier() async {
-    Source source = addSource('''
-class A {
-  int g;
-}
-var a = new A();
-var b = a.g;
-''');
-    var analysisResult = await computeAnalysisResult(source);
-    assertNoErrors(source);
-    TopLevelVariableDeclaration b = analysisResult.unit.declarations[2];
-    expect(b.variables.variables[0].declaredElement.type.toString(), 'int');
-    verify([source]);
-  }
-
-  test_strongMode_topLevelInstanceGetter_implicitlyTyped() async {
-    Source source = addSource('''
-class A {
-  get g => 0;
-}
-var b = new A().g;
-''');
-    await computeAnalysisResult(source);
-    assertErrors(source, [StrongModeCode.TOP_LEVEL_INSTANCE_GETTER]);
-    verify([source]);
-  }
-
-  test_strongMode_topLevelInstanceGetter_implicitlyTyped_call() async {
-    Source source = addSource('''
-class A {
-  get g => () => 0;
-}
-var a = new A();
-var b = a.g();
-''');
-    await computeAnalysisResult(source);
-    assertErrors(source, [StrongModeCode.TOP_LEVEL_INSTANCE_GETTER]);
-    verify([source]);
-  }
-
-  test_strongMode_topLevelInstanceGetter_implicitlyTyped_field() async {
-    Source source = addSource('''
-class A {
-  var g = 0;
-}
-var b = new A().g;
-''');
-    await computeAnalysisResult(source);
-    assertErrors(source, [StrongModeCode.TOP_LEVEL_INSTANCE_GETTER]);
-    verify([source]);
-  }
-
-  test_strongMode_topLevelInstanceGetter_implicitlyTyped_field_call() async {
-    Source source = addSource('''
-class A {
-  var g = () => 0;
-}
-var a = new A();
-var b = a.g();
-''');
-    await computeAnalysisResult(source);
-    assertErrors(source, [StrongModeCode.TOP_LEVEL_INSTANCE_GETTER]);
-    verify([source]);
-  }
-
-  test_strongMode_topLevelInstanceGetter_implicitlyTyped_field_prefixedIdentifier() async {
-    Source source = addSource('''
-class A {
-  var g = 0;
-}
-var a = new A();
-var b = a.g;
-''');
-    await computeAnalysisResult(source);
-    assertErrors(source, [StrongModeCode.TOP_LEVEL_INSTANCE_GETTER]);
-    verify([source]);
-  }
-
-  test_strongMode_topLevelInstanceGetter_implicitlyTyped_fn() async {
-    Source source = addSource('''
-class A {
-  var x = 0;
-}
-int f<T>(x) => 0;
-var a = new A();
-var b = f(a.x);
-''');
-    // The reference to a.x triggers TOP_LEVEL_INSTANCE_GETTER because f is
-    // generic, so the type of a.x might affect the type of b.
-    await computeAnalysisResult(source);
-    assertErrors(source, [StrongModeCode.TOP_LEVEL_INSTANCE_GETTER]);
-    verify([source]);
-  }
-
-  test_strongMode_topLevelInstanceGetter_implicitlyTyped_fn_explicit_type_params() async {
-    Source source = addSource('''
-class A {
-  var x = 0;
-}
-int f<T>(x) => 0;
-var a = new A();
-var b = f<int>(a.x);
-''');
-    // The reference to a.x does not trigger TOP_LEVEL_INSTANCE_GETTER because
-    // it can't possibly affect the type of b.
-    await computeAnalysisResult(source);
-    assertNoErrors(source);
-    verify([source]);
-  }
-
-  test_strongMode_topLevelInstanceGetter_implicitlyTyped_fn_not_generic() async {
-    Source source = addSource('''
-class A {
-  var x = 0;
-}
-int f(x) => 0;
-var a = new A();
-var b = f(a.x);
-''');
-    // The reference to a.x does not trigger TOP_LEVEL_INSTANCE_GETTER because
-    // it can't possibly affect the type of b.
-    await computeAnalysisResult(source);
-    assertNoErrors(source);
-    verify([source]);
-  }
-
-  test_strongMode_topLevelInstanceGetter_implicitlyTyped_indexExpression() async {
-    Source source = addSource('''
-class A {
-  var x = 0;
-  int operator[](int value) => 0;
-}
-var a = new A();
-var b = a[a.x];
-''');
-    // The reference to a.x does not trigger TOP_LEVEL_INSTANCE_GETTER because
-    // it can't possibly affect the type of b.
-    await computeAnalysisResult(source);
-    assertNoErrors(source);
-    verify([source]);
-  }
-
-  test_strongMode_topLevelInstanceGetter_implicitlyTyped_invoke() async {
-    Source source = addSource('''
-class A {
-  var x = 0;
-}
-var a = new A();
-var b = (<T>(y) => 0)(a.x);
-''');
-    // The reference to a.x triggers TOP_LEVEL_INSTANCE_GETTER because the
-    // closure is generic, so the type of a.x might affect the type of b.
-    await computeAnalysisResult(source);
-    assertErrors(source, [StrongModeCode.TOP_LEVEL_INSTANCE_GETTER]);
-    verify([source]);
-  }
-
-  test_strongMode_topLevelInstanceGetter_implicitlyTyped_invoke_explicit_type_params() async {
-    Source source = addSource('''
-class A {
-  var x = 0;
-}
-var a = new A();
-var b = (<T>(y) => 0)<int>(a.x);
-''');
-    // The reference to a.x does not trigger TOP_LEVEL_INSTANCE_GETTER because
-    // it can't possibly affect the type of b.
-    await computeAnalysisResult(source);
-    assertNoErrors(source);
-    verify([source]);
-  }
-
-  test_strongMode_topLevelInstanceGetter_implicitlyTyped_invoke_not_generic() async {
-    Source source = addSource('''
-class A {
-  var x = 0;
-}
-var a = new A();
-var b = ((y) => 0)(a.x);
-''');
-    // The reference to a.x does not trigger TOP_LEVEL_INSTANCE_GETTER because
-    // it can't possibly affect the type of b.
-    await computeAnalysisResult(source);
-    assertNoErrors(source);
-    verify([source]);
-  }
-
-  test_strongMode_topLevelInstanceGetter_implicitlyTyped_method() async {
-    Source source = addSource('''
-class A {
-  var x = 0;
-  int f<T>(int x) => 0;
-}
-var a = new A();
-var b = a.f(a.x);
-''');
-    // The reference to a.x triggers TOP_LEVEL_INSTANCE_GETTER because f is
-    // generic, so the type of a.x might affect the type of b.
-    await computeAnalysisResult(source);
-    assertErrors(source, [StrongModeCode.TOP_LEVEL_INSTANCE_GETTER]);
-    verify([source]);
-  }
-
-  test_strongMode_topLevelInstanceGetter_implicitlyTyped_method_explicit_type_params() async {
-    Source source = addSource('''
-class A {
-  var x = 0;
-  int f<T>(x) => 0;
-}
-var a = new A();
-var b = a.f<int>(a.x);
-''');
-    // The reference to a.x does not trigger TOP_LEVEL_INSTANCE_GETTER because
-    // it can't possibly affect the type of b.
-    await computeAnalysisResult(source);
-    assertNoErrors(source);
-    verify([source]);
-  }
-
-  test_strongMode_topLevelInstanceGetter_implicitlyTyped_method_not_generic() async {
-    Source source = addSource('''
-class A {
-  var x = 0;
-  int f(x) => 0;
-}
-var a = new A();
-var b = a.f(a.x);
-''');
-    // The reference to a.x does not trigger TOP_LEVEL_INSTANCE_GETTER because
-    // it can't possibly affect the type of b.
-    await computeAnalysisResult(source);
-    assertNoErrors(source);
-    verify([source]);
-  }
-
-  test_strongMode_topLevelInstanceGetter_implicitlyTyped_new() async {
-    Source source = addSource('''
-class A {
-  var x = 0;
-}
-class B<T> {
-  B(x);
-}
-var a = new A();
-var b = new B(a.x);
-''');
-    // The reference to a.x triggers TOP_LEVEL_INSTANCE_GETTER because B is
-    // generic, so the type of a.x might affect the type of b.
-    await computeAnalysisResult(source);
-    assertErrors(source, [StrongModeCode.TOP_LEVEL_INSTANCE_GETTER]);
-    verify([source]);
-  }
-
-  test_strongMode_topLevelInstanceGetter_implicitlyTyped_new_explicit_type_params() async {
-    Source source = addSource('''
-class A {
-  var x = 0;
-}
-class B<T> {
-  B(x);
-}
-var a = new A();
-var b = new B<int>(a.x);
-''');
-    // The reference to a.x does not trigger TOP_LEVEL_INSTANCE_GETTER because
-    // it can't possibly affect the type of b.
-    await computeAnalysisResult(source);
-    assertNoErrors(source);
-    verify([source]);
-  }
-
-  test_strongMode_topLevelInstanceGetter_implicitlyTyped_new_explicit_type_params_named() async {
-    Source source = addSource('''
-class A {
-  var x = 0;
-}
-class B<T> {
-  B.named(x);
-}
-var a = new A();
-var b = new B<int>.named(a.x);
-''');
-    // The reference to a.x does not trigger TOP_LEVEL_INSTANCE_GETTER because
-    // it can't possibly affect the type of b.
-    await computeAnalysisResult(source);
-    assertNoErrors(source);
-    verify([source]);
-  }
-
-  test_strongMode_topLevelInstanceGetter_implicitlyTyped_new_explicit_type_params_prefixed() async {
-    addNamedSource('/lib1.dart', '''
-class B<T> {
-  B(x);
-}
-''');
-    Source source = addSource('''
-import 'lib1.dart' as foo;
-class A {
-  var x = 0;
-}
-var a = new A();
-var b = new foo.B<int>(a.x);
-''');
-    // The reference to a.x does not trigger TOP_LEVEL_INSTANCE_GETTER because
-    // it can't possibly affect the type of b.
-    await computeAnalysisResult(source);
-    assertNoErrors(source);
-    verify([source]);
-  }
-
-  test_strongMode_topLevelInstanceGetter_implicitlyTyped_new_named() async {
-    Source source = addSource('''
-class A {
-  var x = 0;
-}
-class B<T> {
-  B.named(x);
-}
-var a = new A();
-var b = new B.named(a.x);
-''');
-    // The reference to a.x triggers TOP_LEVEL_INSTANCE_GETTER because B is
-    // generic, so the type of a.x might affect the type of b.
-    await computeAnalysisResult(source);
-    assertErrors(source, [StrongModeCode.TOP_LEVEL_INSTANCE_GETTER]);
-    verify([source]);
-  }
-
-  test_strongMode_topLevelInstanceGetter_implicitlyTyped_new_not_generic() async {
-    Source source = addSource('''
-class A {
-  var x = 0;
-}
-class B {
-  B(x);
-}
-var a = new A();
-var b = new B(a.x);
-''');
-    // The reference to a.x does not trigger TOP_LEVEL_INSTANCE_GETTER because
-    // it can't possibly affect the type of b.
-    await computeAnalysisResult(source);
-    assertNoErrors(source);
-    verify([source]);
-  }
-
-  test_strongMode_topLevelInstanceGetter_implicitlyTyped_new_not_generic_named() async {
-    Source source = addSource('''
-class A {
-  var x = 0;
-}
-class B {
-  B.named(x);
-}
-var a = new A();
-var b = new B.named(a.x);
-''');
-    // The reference to a.x does not trigger TOP_LEVEL_INSTANCE_GETTER because
-    // it can't possibly affect the type of b.
-    await computeAnalysisResult(source);
-    assertNoErrors(source);
-    verify([source]);
-  }
-
-  test_strongMode_topLevelInstanceGetter_implicitlyTyped_new_not_generic_prefixed() async {
-    addNamedSource('/lib1.dart', '''
-class B {
-  B(x);
-}
-''');
-    Source source = addSource('''
-import 'lib1.dart' as foo;
-class A {
-  var x = 0;
-}
-var a = new A();
-var b = new foo.B(a.x);
-''');
-    // The reference to a.x does not trigger TOP_LEVEL_INSTANCE_GETTER because
-    // it can't possibly affect the type of b.
-    await computeAnalysisResult(source);
-    assertNoErrors(source);
-    verify([source]);
-  }
-
-  test_strongMode_topLevelInstanceGetter_implicitlyTyped_new_prefixed() async {
-    addNamedSource('/lib1.dart', '''
-class B<T> {
-  B(x);
-}
-''');
-    Source source = addSource('''
-import 'lib1.dart' as foo;
-class A {
-  var x = 0;
-}
-var a = new A();
-var b = new foo.B(a.x);
-''');
-    // The reference to a.x triggers TOP_LEVEL_INSTANCE_GETTER because B is
-    // generic, so the type of a.x might affect the type of b.
-    await computeAnalysisResult(source);
-    assertErrors(source, [StrongModeCode.TOP_LEVEL_INSTANCE_GETTER]);
-    verify([source]);
-  }
-
-  test_strongMode_topLevelInstanceGetter_implicitlyTyped_prefixedIdentifier() async {
-    Source source = addSource('''
-class A {
-  get g => 0;
-}
-var a = new A();
-var b = a.g;
-''');
-    await computeAnalysisResult(source);
-    assertErrors(source, [StrongModeCode.TOP_LEVEL_INSTANCE_GETTER]);
-    verify([source]);
-  }
-
-  test_strongMode_topLevelInstanceGetter_implicitlyTyped_propertyAccessLhs() async {
-    Source source = addSource('''
-class A {
-  var x = new B();
-  int operator[](int value) => 0;
-}
-class B {
-  int y;
-}
-var a = new A();
-var b = (a.x).y;
-''');
-    // The reference to a.x triggers TOP_LEVEL_INSTANCE_GETTER because the type
-    // of a.x affects the lookup of y, which in turn affects the type of b.
-    await computeAnalysisResult(source);
-    assertErrors(source, [StrongModeCode.TOP_LEVEL_INSTANCE_GETTER]);
-    verify([source]);
-  }
-
-  test_strongMode_topLevelInstanceGetter_prefixedIdentifier() async {
-    Source source = addSource('''
-class A {
-  int get g => 0;
-}
-var a = new A();
-var b = a.g;
-''');
-    var analysisResult = await computeAnalysisResult(source);
-    assertNoErrors(source);
-    TopLevelVariableDeclaration b = analysisResult.unit.declarations[2];
-    expect(b.variables.variables[0].declaredElement.type.toString(), 'int');
-    verify([source]);
-  }
-
-  test_strongMode_topLevelInstanceMethod() async {
-    Source source = addSource('''
-class A {
-  f() => 0;
-}
-var x = new A().f();
-''');
-    await computeAnalysisResult(source);
-    assertErrors(source, [StrongModeCode.TOP_LEVEL_INSTANCE_METHOD]);
-    verify([source]);
-  }
-
-  test_strongMode_topLevelInstanceMethod_parameter() async {
-    Source source = addSource('''
-class A {
-  int f(v) => 0;
-}
-var x = new A().f(0);
-''');
-    await computeAnalysisResult(source);
-    assertNoErrors(source);
-    verify([source]);
-  }
-
-  test_strongMode_topLevelInstanceMethod_parameter_generic() async {
-    Source source = addSource('''
-class A {
-  int f<T>(v) => 0;
-}
-var x = new A().f(0);
-''');
-    await computeAnalysisResult(source);
-    assertErrors(source, [StrongModeCode.TOP_LEVEL_INSTANCE_METHOD]);
-    verify([source]);
-  }
-
-  test_strongMode_topLevelInstanceMethod_parameter_generic_explicit() async {
-    Source source = addSource('''
-class A {
-  int f<T>(v) => 0;
-}
-var x = new A().f<int>(0);
-''');
-    await computeAnalysisResult(source);
-    assertNoErrors(source);
-    verify([source]);
-  }
-
-  test_strongMode_topLevelInstanceMethod_static() async {
-    Source source = addSource('''
-class A {
-  static f() => 0;
-}
-var x = A.f();
-''');
-    await computeAnalysisResult(source);
-    assertNoErrors(source);
-    verify([source]);
-  }
-
-  test_strongMode_topLevelInstanceMethod_tearoff() async {
-    Source source = addSource('''
-class A {
-  f() => 0;
-}
-var x = new A().f;
-''');
-    await computeAnalysisResult(source);
-    assertErrors(source, [StrongModeCode.TOP_LEVEL_INSTANCE_METHOD]);
-    verify([source]);
-  }
-
-  test_strongMode_topLevelInstanceMethod_tearoff_parameter() async {
-    Source source = addSource('''
-class A {
-  int f(v) => 0;
-}
-var x = new A().f;
-''');
-    await computeAnalysisResult(source);
-    assertErrors(source, [StrongModeCode.TOP_LEVEL_INSTANCE_METHOD]);
-    verify([source]);
-  }
-
-  test_strongMode_topLevelInstanceMethod_tearoff_static() async {
-    Source source = addSource('''
-class A {
-  static f() => 0;
-}
-var x = A.f;
-''');
-    await computeAnalysisResult(source);
-    assertNoErrors(source);
-    verify([source]);
-  }
-
-  test_typeCheck_type_is_Null() async {
-    Source source = addSource(r'''
-m(i) {
-  bool b = i is Null;
-}''');
-    await computeAnalysisResult(source);
-    assertErrors(source, [HintCode.TYPE_CHECK_IS_NULL]);
-    verify([source]);
-  }
-
-  test_typeCheck_type_not_Null() async {
-    Source source = addSource(r'''
-m(i) {
-  bool b = i is! Null;
-}''');
-    await computeAnalysisResult(source);
-    assertErrors(source, [HintCode.TYPE_CHECK_IS_NOT_NULL]);
-    verify([source]);
-  }
-
-  test_undefinedGetter() async {
-    Source source = addSource(r'''
-class A {}
-f(var a) {
-  if(a is A) {
-    return a.m;
-  }
-}''');
-    await computeAnalysisResult(source);
-    assertErrors(source, [StaticTypeWarningCode.UNDEFINED_GETTER]);
-  }
-
-  test_undefinedIdentifier_exportHide() async {
-    Source source = addSource(r'''
-library L;
-export 'lib1.dart' hide a;''');
-    addNamedSource("/lib1.dart", "library lib1;");
-    await computeAnalysisResult(source);
-    assertErrors(source, [HintCode.UNDEFINED_HIDDEN_NAME]);
-    verify([source]);
-  }
-
-  test_undefinedIdentifier_exportShow() async {
-    Source source = addSource(r'''
-library L;
-export 'lib1.dart' show a;''');
-    addNamedSource("/lib1.dart", "library lib1;");
-    await computeAnalysisResult(source);
-    assertErrors(source, [HintCode.UNDEFINED_SHOWN_NAME]);
-    verify([source]);
-  }
-
-  test_undefinedIdentifier_importHide() async {
-    Source source = addSource(r'''
-library L;
-import 'lib1.dart' hide a;''');
-    addNamedSource("/lib1.dart", "library lib1;");
-    await computeAnalysisResult(source);
-    assertErrors(
-        source, [HintCode.UNUSED_IMPORT, HintCode.UNDEFINED_HIDDEN_NAME]);
-    verify([source]);
-  }
-
-  test_undefinedIdentifier_importShow() async {
-    Source source = addSource(r'''
-library L;
-import 'lib1.dart' show a;''');
-    addNamedSource("/lib1.dart", "library lib1;");
-    await computeAnalysisResult(source);
-    assertErrors(
-        source, [HintCode.UNUSED_IMPORT, HintCode.UNDEFINED_SHOWN_NAME]);
-    verify([source]);
-  }
-
-  test_undefinedOperator_binaryExpression() async {
-    Source source = addSource(r'''
-class A {}
-f(var a) {
-  if(a is A) {
-    a + 1;
-  }
-}''');
-    await computeAnalysisResult(source);
-    assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]);
-  }
-
-  test_undefinedOperator_indexBoth() async {
-    Source source = addSource(r'''
-class A {}
-f(var a) {
-  if(a is A) {
-    a[0]++;
-  }
-}''');
-    await computeAnalysisResult(source);
-    assertErrors(source, [
-      StaticTypeWarningCode.UNDEFINED_OPERATOR,
-      StaticTypeWarningCode.UNDEFINED_OPERATOR,
-    ]);
-  }
-
-  test_undefinedOperator_indexGetter() async {
-    Source source = addSource(r'''
-class A {}
-f(var a) {
-  if(a is A) {
-    a[0];
-  }
-}''');
-    await computeAnalysisResult(source);
-    assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]);
-  }
-
-  test_undefinedOperator_indexSetter() async {
-    Source source = addSource(r'''
-class A {}
-f(var a) {
-  if(a is A) {
-    a[0] = 1;
-  }
-}''');
-    await computeAnalysisResult(source);
-    assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]);
-  }
-
-  test_undefinedOperator_postfixExpression() async {
-    Source source = addSource(r'''
-class A {}
-f(var a) {
-  if(a is A) {
-    a++;
-  }
-}''');
-    await computeAnalysisResult(source);
-    assertNoErrors(source);
-  }
-
-  test_undefinedOperator_prefixExpression() async {
-    Source source = addSource(r'''
-class A {}
-f(var a) {
-  if(a is A) {
-    ++a;
-  }
-}''');
-    await computeAnalysisResult(source);
-    assertNoErrors(source);
-  }
-
-  test_undefinedSetter() async {
-    Source source = addSource(r'''
-class A {}
-f(var a) {
-  if(a is A) {
-    a.m = 0;
-  }
-}''');
-    await computeAnalysisResult(source);
-    assertErrors(source, [StaticTypeWarningCode.UNDEFINED_SETTER]);
-  }
-
-  test_unnecessaryNoSuchMethod_blockBody() async {
-    Source source = addSource(r'''
-class A {
-  noSuchMethod(x) => super.noSuchMethod(x);
-}
-class B extends A {
-  mmm();
-  noSuchMethod(y) {
-    return super.noSuchMethod(y);
-  }
-}''');
-    await computeAnalysisResult(source);
-    assertErrors(source, [HintCode.UNNECESSARY_NO_SUCH_METHOD]);
-    verify([source]);
-  }
-
-  test_unnecessaryNoSuchMethod_expressionBody() async {
-    Source source = addSource(r'''
-class A {
-  noSuchMethod(x) => super.noSuchMethod(x);
-}
-class B extends A {
-  mmm();
-  noSuchMethod(y) => super.noSuchMethod(y);
-}''');
-    await computeAnalysisResult(source);
-    assertErrors(source, [HintCode.UNNECESSARY_NO_SUCH_METHOD]);
-    verify([source]);
-  }
-
-  test_unnecessaryTypeCheck_null_is_Null() async {
-    Source source = addSource("bool b = null is Null;");
-    await computeAnalysisResult(source);
-    assertErrors(source, [HintCode.UNNECESSARY_TYPE_CHECK_TRUE]);
-    verify([source]);
-  }
-
-  test_unnecessaryTypeCheck_null_not_Null() async {
-    Source source = addSource("bool b = null is! Null;");
-    await computeAnalysisResult(source);
-    assertErrors(source, [HintCode.UNNECESSARY_TYPE_CHECK_FALSE]);
-    verify([source]);
-  }
-
-  test_unnecessaryTypeCheck_type_is_dynamic() async {
-    Source source = addSource(r'''
-m(i) {
-  bool b = i is dynamic;
-}''');
-    await computeAnalysisResult(source);
-    assertErrors(source, [HintCode.UNNECESSARY_TYPE_CHECK_TRUE]);
-    verify([source]);
-  }
-
-  test_unnecessaryTypeCheck_type_is_object() async {
-    Source source = addSource(r'''
-m(i) {
-  bool b = i is Object;
-}''');
-    await computeAnalysisResult(source);
-    assertErrors(source, [HintCode.UNNECESSARY_TYPE_CHECK_TRUE]);
-    verify([source]);
-  }
-
-  test_unnecessaryTypeCheck_type_not_dynamic() async {
-    Source source = addSource(r'''
-m(i) {
-  bool b = i is! dynamic;
-}''');
-    await computeAnalysisResult(source);
-    assertErrors(source, [HintCode.UNNECESSARY_TYPE_CHECK_FALSE]);
-    verify([source]);
-  }
-
-  test_unnecessaryTypeCheck_type_not_object() async {
-    Source source = addSource(r'''
-m(i) {
-  bool b = i is! Object;
-}''');
-    await computeAnalysisResult(source);
-    assertErrors(source, [HintCode.UNNECESSARY_TYPE_CHECK_FALSE]);
-    verify([source]);
-  }
-
-  test_unusedElement_class_isUsed_extends() async {
-    enableUnusedElement = true;
-    Source source = addSource(r'''
-class _A {}
-class B extends _A {}
-''');
-    await computeAnalysisResult(source);
-    assertNoErrors(source);
-    verify([source]);
-  }
-
-  test_unusedElement_class_isUsed_fieldDeclaration() async {
-    enableUnusedElement = true;
-    var src = r'''
-class Foo {
-  _Bar x;
-}
-
-class _Bar {
-}
-''';
-    Source source = addSource(src);
-    await computeAnalysisResult(source);
-    assertNoErrors(source);
-    verify([source]);
-  }
-
-  test_unusedElement_class_isUsed_implements() async {
-    enableUnusedElement = true;
-    Source source = addSource(r'''
-class _A {}
-class B implements _A {}
-''');
-    await computeAnalysisResult(source);
-    assertNoErrors(source);
-    verify([source]);
-  }
-
-  test_unusedElement_class_isUsed_instanceCreation() async {
-    enableUnusedElement = true;
-    Source source = addSource(r'''
-class _A {}
-main() {
-  new _A();
-}''');
-    await computeAnalysisResult(source);
-    assertNoErrors(source);
-    verify([source]);
-  }
-
-  test_unusedElement_class_isUsed_staticFieldAccess() async {
-    enableUnusedElement = true;
-    Source source = addSource(r'''
-class _A {
-  static const F = 42;
-}
-main() {
-  _A.F;
-}''');
-    await computeAnalysisResult(source);
-    assertNoErrors(source);
-    verify([source]);
-  }
-
-  test_unusedElement_class_isUsed_staticMethodInvocation() async {
-    enableUnusedElement = true;
-    Source source = addSource(r'''
-class _A {
-  static m() {}
-}
-main() {
-  _A.m();
-}''');
-    await computeAnalysisResult(source);
-    assertNoErrors(source);
-    verify([source]);
-  }
-
-  test_unusedElement_class_isUsed_typeArgument() async {
-    enableUnusedElement = true;
-    Source source = addSource(r'''
-class _A {}
-main() {
-  var v = new List<_A>();
-  print(v);
-}''');
-    await computeAnalysisResult(source);
-    assertNoErrors(source);
-    verify([source]);
-  }
-
-  test_unusedElement_class_notUsed_inClassMember() async {
-    enableUnusedElement = true;
-    Source source = addSource(r'''
-class _A {
-  static staticMethod() {
-    new _A();
-  }
-  instanceMethod() {
-    new _A();
-  }
-}
-''');
-    await computeAnalysisResult(source);
-    assertErrors(source, [HintCode.UNUSED_ELEMENT]);
-    verify([source]);
-  }
-
-  test_unusedElement_class_notUsed_inConstructorName() async {
-    enableUnusedElement = true;
-    Source source = addSource(r'''
-class _A {
-  _A() {}
-  _A.named() {}
-}
-''');
-    await computeAnalysisResult(source);
-    assertErrors(source, [HintCode.UNUSED_ELEMENT]);
-    verify([source]);
-  }
-
-  test_unusedElement_class_notUsed_isExpression() async {
-    enableUnusedElement = true;
-    Source source = addSource(r'''
-class _A {}
-main(p) {
-  if (p is _A) {
-  }
-}
-''');
-    await computeAnalysisResult(source);
-    assertErrors(source, [HintCode.UNUSED_ELEMENT]);
-    verify([source]);
-  }
-
-  test_unusedElement_class_notUsed_noReference() async {
-    enableUnusedElement = true;
-    Source source = addSource(r'''
-class _A {}
-main() {
-}''');
-    await computeAnalysisResult(source);
-    assertErrors(source, [HintCode.UNUSED_ELEMENT]);
-    verify([source]);
-  }
-
-  test_unusedElement_class_notUsed_variableDeclaration() async {
-    enableUnusedElement = true;
-    Source source = addSource(r'''
-class _A {}
-main() {
-  _A v;
-  print(v);
-}
-print(x) {}
-''');
-    await computeAnalysisResult(source);
-    assertErrors(source, [HintCode.UNUSED_ELEMENT]);
-    verify([source]);
-  }
-
-  test_unusedElement_enum_isUsed_fieldReference() async {
-    enableUnusedElement = true;
-    Source source = addSource(r'''
-enum _MyEnum {A, B, C}
-main() {
-  print(_MyEnum.B);
-}''');
-    await computeAnalysisResult(source);
-    assertNoErrors(source);
-    verify([source]);
-  }
-
-  test_unusedElement_enum_notUsed_noReference() async {
-    enableUnusedElement = true;
-    Source source = addSource(r'''
-enum _MyEnum {A, B, C}
-main() {
-}''');
-    await computeAnalysisResult(source);
-    assertErrors(source, [HintCode.UNUSED_ELEMENT]);
-    verify([source]);
-  }
-
-  test_unusedElement_functionLocal_isUsed_closure() async {
-    enableUnusedElement = true;
-    Source source = addSource(r'''
-main() {
-  print(() {});
-}
-print(x) {}
-''');
-    await computeAnalysisResult(source);
-    assertNoErrors(source);
-    verify([source]);
-  }
-
-  test_unusedElement_functionLocal_isUsed_invocation() async {
-    enableUnusedElement = true;
-    Source source = addSource(r'''
-main() {
-  f() {}
-  f();
-}''');
-    await computeAnalysisResult(source);
-    assertNoErrors(source);
-    verify([source]);
-  }
-
-  test_unusedElement_functionLocal_isUsed_reference() async {
-    enableUnusedElement = true;
-    Source source = addSource(r'''
-main() {
-  f() {}
-  print(f);
-}
-print(x) {}
-''');
-    await computeAnalysisResult(source);
-    assertNoErrors(source);
-    verify([source]);
-  }
-
-  test_unusedElement_functionLocal_notUsed_noReference() async {
-    enableUnusedElement = true;
-    Source source = addSource(r'''
-main() {
-  f() {}
-}''');
-    await computeAnalysisResult(source);
-    assertErrors(source, [HintCode.UNUSED_ELEMENT]);
-    verify([source]);
-  }
-
-  test_unusedElement_functionLocal_notUsed_referenceFromItself() async {
-    enableUnusedElement = true;
-    Source source = addSource(r'''
-main() {
-  _f(int p) {
-    _f(p - 1);
-  }
-}''');
-    await computeAnalysisResult(source);
-    assertErrors(source, [HintCode.UNUSED_ELEMENT]);
-    verify([source]);
-  }
-
-  test_unusedElement_functionTop_isUsed_invocation() async {
-    enableUnusedElement = true;
-    Source source = addSource(r'''
-_f() {}
-main() {
-  _f();
-}''');
-    await computeAnalysisResult(source);
-    assertNoErrors(source);
-    verify([source]);
-  }
-
-  test_unusedElement_functionTop_isUsed_reference() async {
-    enableUnusedElement = true;
-    Source source = addSource(r'''
-_f() {}
-main() {
-  print(_f);
-}
-print(x) {}
-''');
-    await computeAnalysisResult(source);
-    assertNoErrors(source);
-    verify([source]);
-  }
-
-  test_unusedElement_functionTop_notUsed_noReference() async {
-    enableUnusedElement = true;
-    Source source = addSource(r'''
-_f() {}
-main() {
-}''');
-    await computeAnalysisResult(source);
-    assertErrors(source, [HintCode.UNUSED_ELEMENT]);
-    verify([source]);
-  }
-
-  test_unusedElement_functionTop_notUsed_referenceFromItself() async {
-    enableUnusedElement = true;
-    Source source = addSource(r'''
-_f(int p) {
-  _f(p - 1);
-}
-main() {
-}''');
-    await computeAnalysisResult(source);
-    assertErrors(source, [HintCode.UNUSED_ELEMENT]);
-    verify([source]);
-  }
-
-  test_unusedElement_functionTypeAlias_isUsed_isExpression() async {
-    enableUnusedElement = true;
-    Source source = addSource(r'''
-typedef _F(a, b);
-main(f) {
-  if (f is _F) {
-    print('F');
-  }
-}''');
-    await computeAnalysisResult(source);
-    assertNoErrors(source);
-    verify([source]);
-  }
-
-  test_unusedElement_functionTypeAlias_isUsed_reference() async {
-    enableUnusedElement = true;
-    Source source = addSource(r'''
-typedef _F(a, b);
-main(_F f) {
-}''');
-    await computeAnalysisResult(source);
-    assertNoErrors(source);
-    verify([source]);
-  }
-
-  test_unusedElement_functionTypeAlias_isUsed_typeArgument() async {
-    enableUnusedElement = true;
-    Source source = addSource(r'''
-typedef _F(a, b);
-main() {
-  var v = new List<_F>();
-  print(v);
-}''');
-    await computeAnalysisResult(source);
-    assertNoErrors(source);
-    verify([source]);
-  }
-
-  test_unusedElement_functionTypeAlias_isUsed_variableDeclaration() async {
-    enableUnusedElement = true;
-    Source source = addSource(r'''
-typedef _F(a, b);
-class A {
-  _F f;
-}''');
-    await computeAnalysisResult(source);
-    assertNoErrors(source);
-    verify([source]);
-  }
-
-  test_unusedElement_functionTypeAlias_notUsed_noReference() async {
-    enableUnusedElement = true;
-    Source source = addSource(r'''
-typedef _F(a, b);
-main() {
-}''');
-    await computeAnalysisResult(source);
-    assertErrors(source, [HintCode.UNUSED_ELEMENT]);
-    verify([source]);
-  }
-
-  test_unusedElement_getter_isUsed_invocation_implicitThis() async {
-    enableUnusedElement = true;
-    Source source = addSource(r'''
-class A {
-  get _g => null;
-  useGetter() {
-    var v = _g;
-  }
-}''');
-    await computeAnalysisResult(source);
-    assertNoErrors(source);
-    verify([source]);
-  }
-
-  test_unusedElement_getter_isUsed_invocation_PrefixedIdentifier() async {
-    enableUnusedElement = true;
-    Source source = addSource(r'''
-class A {
-  get _g => null;
-}
-main(A a) {
-  var v = a._g;
-}
-''');
-    await computeAnalysisResult(source);
-    assertNoErrors(source);
-    verify([source]);
-  }
-
-  test_unusedElement_getter_isUsed_invocation_PropertyAccess() async {
-    enableUnusedElement = true;
-    Source source = addSource(r'''
-class A {
-  get _g => null;
-}
-main() {
-  var v = new A()._g;
-}
-''');
-    await computeAnalysisResult(source);
-    assertNoErrors(source);
-    verify([source]);
-  }
-
-  test_unusedElement_getter_notUsed_noReference() async {
-    enableUnusedElement = true;
-    Source source = addSource(r'''
-class A {
-  get _g => null;
-}''');
-    await computeAnalysisResult(source);
-    assertErrors(source, [HintCode.UNUSED_ELEMENT]);
-    verify([source]);
-  }
-
-  test_unusedElement_getter_notUsed_referenceFromItself() async {
-    enableUnusedElement = true;
-    Source source = addSource(r'''
-class A {
-  get _g {
-    return _g;
-  }
-}''');
-    await computeAnalysisResult(source);
-    assertErrors(source, [HintCode.UNUSED_ELEMENT]);
-    verify([source]);
-  }
-
-  test_unusedElement_method_isUsed_hasReference_implicitThis() async {
-    enableUnusedElement = true;
-    Source source = addSource(r'''
-class A {
-  _m() {}
-  useMethod() {
-    print(_m);
-  }
-}
-print(x) {}
-''');
-    await computeAnalysisResult(source);
-    assertNoErrors(source);
-    verify([source]);
-  }
-
-  test_unusedElement_method_isUsed_hasReference_implicitThis_subclass() async {
-    enableUnusedElement = true;
-    Source source = addSource(r'''
-class A {
-  _m() {}
-  useMethod() {
-    print(_m);
-  }
-}
-class B extends A {
-  _m() {}
-}
-print(x) {}
-''');
-    await computeAnalysisResult(source);
-    assertNoErrors(source);
-    verify([source]);
-  }
-
-  test_unusedElement_method_isUsed_hasReference_PrefixedIdentifier() async {
-    enableUnusedElement = true;
-    Source source = addSource(r'''
-class A {
-  _m() {}
-}
-main(A a) {
-  a._m;
-}''');
-    await computeAnalysisResult(source);
-    assertNoErrors(source);
-    verify([source]);
-  }
-
-  test_unusedElement_method_isUsed_hasReference_PropertyAccess() async {
-    enableUnusedElement = true;
-    Source source = addSource(r'''
-class A {
-  _m() {}
-}
-main() {
-  new A()._m;
-}''');
-    await computeAnalysisResult(source);
-    assertNoErrors(source);
-    verify([source]);
-  }
-
-  test_unusedElement_method_isUsed_invocation_implicitThis() async {
-    enableUnusedElement = true;
-    Source source = addSource(r'''
-class A {
-  _m() {}
-  useMethod() {
-    _m();
-  }
-}''');
-    await computeAnalysisResult(source);
-    assertNoErrors(source);
-    verify([source]);
-  }
-
-  test_unusedElement_method_isUsed_invocation_implicitThis_subclass() async {
-    enableUnusedElement = true;
-    Source source = addSource(r'''
-class A {
-  _m() {}
-  useMethod() {
-    _m();
-  }
-}
-class B extends A {
-  _m() {}
-}''');
-    await computeAnalysisResult(source);
-    assertNoErrors(source);
-    verify([source]);
-  }
-
-  test_unusedElement_method_isUsed_invocation_MemberElement() async {
-    enableUnusedElement = true;
-    Source source = addSource(r'''
-class A<T> {
-  _m(T t) {}
-}
-main(A<int> a) {
-  a._m(0);
-}''');
-    await computeAnalysisResult(source);
-    assertNoErrors(source);
-    verify([source]);
-  }
-
-  test_unusedElement_method_isUsed_invocation_propagated() async {
-    enableUnusedElement = true;
-    Source source = addSource(r'''
-class A {
-  _m() {}
-}
-main() {
-  var a = new A();
-  a._m();
-}''');
-    await computeAnalysisResult(source);
-    assertNoErrors(source);
-    verify([source]);
-  }
-
-  test_unusedElement_method_isUsed_invocation_static() async {
-    enableUnusedElement = true;
-    Source source = addSource(r'''
-class A {
-  _m() {}
-}
-main() {
-  A a = new A();
-  a._m();
-}''');
-    await computeAnalysisResult(source);
-    assertNoErrors(source);
-    verify([source]);
-  }
-
-  test_unusedElement_method_isUsed_invocation_subclass() async {
-    enableUnusedElement = true;
-    Source source = addSource(r'''
-class A {
-  _m() {}
-}
-class B extends A {
-  _m() {}
-}
-main(A a) {
-  a._m();
-}''');
-    await computeAnalysisResult(source);
-    assertNoErrors(source);
-    verify([source]);
-  }
-
-  test_unusedElement_method_isUsed_notPrivate() async {
-    enableUnusedElement = true;
-    Source source = addSource(r'''
-class A {
-  m() {}
-}
-main() {
-}''');
-    await computeAnalysisResult(source);
-    assertNoErrors(source);
-    verify([source]);
-  }
-
-  test_unusedElement_method_isUsed_staticInvocation() async {
-    enableUnusedElement = true;
-    Source source = addSource(r'''
-class A {
-  static _m() {}
-}
-main() {
-  A._m();
-}''');
-    await computeAnalysisResult(source);
-    assertNoErrors(source);
-    verify([source]);
-  }
-
-  test_unusedElement_method_notUsed_noReference() async {
-    enableUnusedElement = true;
-    Source source = addSource(r'''
-class A {
-  static _m() {}
-}''');
-    await computeAnalysisResult(source);
-    assertErrors(source, [HintCode.UNUSED_ELEMENT]);
-    verify([source]);
-  }
-
-  test_unusedElement_method_notUsed_referenceFromItself() async {
-    enableUnusedElement = true;
-    Source source = addSource(r'''
-class A {
-  static _m(int p) {
-    _m(p - 1);
-  }
-}''');
-    await computeAnalysisResult(source);
-    assertErrors(source, [HintCode.UNUSED_ELEMENT]);
-    verify([source]);
-  }
-
-  test_unusedElement_setter_isUsed_invocation_implicitThis() async {
-    enableUnusedElement = true;
-    Source source = addSource(r'''
-class A {
-  set _s(x) {}
-  useSetter() {
-    _s = 42;
-  }
-}''');
-    await computeAnalysisResult(source);
-    assertNoErrors(source);
-    verify([source]);
-  }
-
-  test_unusedElement_setter_isUsed_invocation_PrefixedIdentifier() async {
-    enableUnusedElement = true;
-    Source source = addSource(r'''
-class A {
-  set _s(x) {}
-}
-main(A a) {
-  a._s = 42;
-}
-''');
-    await computeAnalysisResult(source);
-    assertNoErrors(source);
-    verify([source]);
-  }
-
-  test_unusedElement_setter_isUsed_invocation_PropertyAccess() async {
-    enableUnusedElement = true;
-    Source source = addSource(r'''
-class A {
-  set _s(x) {}
-}
-main() {
-  new A()._s = 42;
-}
-''');
-    await computeAnalysisResult(source);
-    assertNoErrors(source);
-    verify([source]);
-  }
-
-  test_unusedElement_setter_notUsed_noReference() async {
-    enableUnusedElement = true;
-    Source source = addSource(r'''
-class A {
-  set _s(x) {}
-}''');
-    await computeAnalysisResult(source);
-    assertErrors(source, [HintCode.UNUSED_ELEMENT]);
-    verify([source]);
-  }
-
-  test_unusedElement_setter_notUsed_referenceFromItself() async {
-    enableUnusedElement = true;
-    Source source = addSource(r'''
-class A {
-  set _s(int x) {
-    if (x > 5) {
-      _s = x - 1;
-    }
-  }
-}''');
-    await computeAnalysisResult(source);
-    assertErrors(source, [HintCode.UNUSED_ELEMENT]);
-    verify([source]);
-  }
-
-  test_unusedElement_topLevelVariable_isUsed() async {
-    enableUnusedElement = true;
-    Source source = addSource(r'''
-int _a = 1;
-main() {
-  _a;
-}
-''');
-    await computeAnalysisResult(source);
-    assertNoErrors(source);
-    verify([source]);
-  }
-
-  test_unusedElement_topLevelVariable_isUsed_plusPlus() async {
-    enableUnusedElement = true;
-    Source source = addSource(r'''
-int _a = 0;
-main() {
-  var b = _a++;
-  b;
-}
-''');
-    await computeAnalysisResult(source);
-    assertNoErrors(source);
-    verify([source]);
-  }
-
-  test_unusedElement_topLevelVariable_notUsed() async {
-    enableUnusedElement = true;
-    Source source = addSource(r'''
-int _a = 1;
-main() {
-  _a = 2;
-}
-''');
-    await computeAnalysisResult(source);
-    assertErrors(source, [HintCode.UNUSED_ELEMENT]);
-    verify([source]);
-  }
-
-  test_unusedLocalVariable_inCatch_exception() async {
-    enableUnusedLocalVariable = true;
-    Source source = addSource(r'''
-main() {
-  try {
-  } on String catch (exception) {
-  }
-}''');
-    await computeAnalysisResult(source);
-    assertErrors(source, [HintCode.UNUSED_CATCH_CLAUSE]);
-    verify([source]);
-  }
-
-  test_unusedLocalVariable_inCatch_exception_hasStack() async {
-    enableUnusedLocalVariable = true;
-    Source source = addSource(r'''
-main() {
-  try {
-  } catch (exception, stack) {
-    print(stack);
-  }
-}''');
-    await computeAnalysisResult(source);
-    assertNoErrors(source);
-    verify([source]);
-  }
-
-  test_unusedLocalVariable_inCatch_exception_noOnClause() async {
-    enableUnusedLocalVariable = true;
-    Source source = addSource(r'''
-main() {
-  try {
-  } catch (exception) {
-  }
-}''');
-    await computeAnalysisResult(source);
-    assertNoErrors(source);
-    verify([source]);
-  }
-
-  test_unusedLocalVariable_inCatch_stackTrace() async {
-    enableUnusedLocalVariable = true;
-    Source source = addSource(r'''
-main() {
-  try {
-  } catch (exception, stackTrace) {
-  }
-}''');
-    await computeAnalysisResult(source);
-    assertErrors(source, [HintCode.UNUSED_CATCH_STACK]);
-    verify([source]);
-  }
-
-  test_unusedLocalVariable_inCatch_stackTrace_used() async {
-    enableUnusedLocalVariable = true;
-    Source source = addSource(r'''
-main() {
-  try {
-  } catch (exception, stackTrace) {
-    print('exception at $stackTrace');
-  }
-}
-print(x) {}''');
-    await computeAnalysisResult(source);
-    assertErrors(source);
-    verify([source]);
-  }
-
-  test_unusedLocalVariable_inFor_underscore_ignored() async {
-    enableUnusedLocalVariable = true;
-    Source source = addSource(r'''
-main() {
-  for (var _ in [1,2,3]) {
-    for (var __ in [4,5,6]) {
-      // do something
-    }
-  }
-}''');
-    await computeAnalysisResult(source);
-    assertErrors(source);
-    verify([source]);
-  }
-
-  test_unusedLocalVariable_inFunction() async {
-    enableUnusedLocalVariable = true;
-    Source source = addSource(r'''
-main() {
-  var v = 1;
-  v = 2;
-}''');
-    await computeAnalysisResult(source);
-    assertErrors(source, [HintCode.UNUSED_LOCAL_VARIABLE]);
-    verify([source]);
-  }
-
-  test_unusedLocalVariable_inMethod() async {
-    enableUnusedLocalVariable = true;
-    Source source = addSource(r'''
-class A {
-  foo() {
-    var v = 1;
-    v = 2;
-  }
-}''');
-    await computeAnalysisResult(source);
-    assertErrors(source, [HintCode.UNUSED_LOCAL_VARIABLE]);
-    verify([source]);
-  }
-
-  test_unusedLocalVariable_isInvoked() async {
-    enableUnusedLocalVariable = true;
-    Source source = addSource(r'''
-typedef Foo();
-main() {
-  Foo foo;
-  foo();
-}''');
-    await computeAnalysisResult(source);
-    assertErrors(source);
-    verify([source]);
-  }
-
-  test_unusedLocalVariable_isNullAssigned() async {
-    enableUnusedLocalVariable = true;
-    Source source = addSource(r'''
-typedef Foo();
-main() {
-  var v;
-  v ??= doSomething();
-}
-doSomething() => 42;
-''');
-    await computeAnalysisResult(source);
-    assertErrors(source);
-    verify([source]);
-  }
-
-  test_unusedLocalVariable_isRead_notUsed_compoundAssign() async {
-    enableUnusedLocalVariable = true;
-    Source source = addSource(r'''
-main() {
-  var v = 1;
-  v += 2;
-}''');
-    await computeAnalysisResult(source);
-    assertErrors(source, [HintCode.UNUSED_LOCAL_VARIABLE]);
-    verify([source]);
-  }
-
-  test_unusedLocalVariable_isRead_notUsed_postfixExpr() async {
-    enableUnusedLocalVariable = true;
-    Source source = addSource(r'''
-main() {
-  var v = 1;
-  v++;
-}''');
-    await computeAnalysisResult(source);
-    assertErrors(source, [HintCode.UNUSED_LOCAL_VARIABLE]);
-    verify([source]);
-  }
-
-  test_unusedLocalVariable_isRead_notUsed_prefixExpr() async {
-    enableUnusedLocalVariable = true;
-    Source source = addSource(r'''
-main() {
-  var v = 1;
-  ++v;
-}''');
-    await computeAnalysisResult(source);
-    assertErrors(source, [HintCode.UNUSED_LOCAL_VARIABLE]);
-    verify([source]);
-  }
-
-  test_unusedLocalVariable_isRead_usedArgument() async {
-    enableUnusedLocalVariable = true;
-    Source source = addSource(r'''
-main() {
-  var v = 1;
-  print(++v);
-}
-print(x) {}''');
-    await computeAnalysisResult(source);
-    assertErrors(source);
-    verify([source]);
-  }
-
-  test_unusedLocalVariable_isRead_usedInvocationTarget() async {
-    enableUnusedLocalVariable = true;
-    Source source = addSource(r'''
-class A {
-  foo() {}
-}
-main() {
-  var a = new A();
-  a.foo();
-}
-''');
-    await computeAnalysisResult(source);
-    assertErrors(source);
-    verify([source]);
-  }
 }
diff --git a/pkg/analyzer/test/generated/non_hint_code.dart b/pkg/analyzer/test/generated/non_hint_code.dart
index 800b3c1..206e154 100644
--- a/pkg/analyzer/test/generated/non_hint_code.dart
+++ b/pkg/analyzer/test/generated/non_hint_code.dart
@@ -765,21 +765,6 @@
     assertNoErrors(source);
   }
 
-  test_undefinedGetter_inSubtype() async {
-    Source source = addSource(r'''
-class A {}
-class B extends A {
-  get b => 0;
-}
-f(var a) {
-  if(a is A) {
-    return a.b;
-  }
-}''');
-    await computeAnalysisResult(source);
-    assertErrors(source, [StaticTypeWarningCode.UNDEFINED_GETTER]);
-  }
-
   test_undefinedMethod_assignmentExpression_inSubtype() async {
     Source source = addSource(r'''
 class A {}
@@ -844,175 +829,6 @@
     await computeAnalysisResult(source);
     assertNoErrors(source);
   }
-
-  test_undefinedOperator_binaryExpression_inSubtype() async {
-    Source source = addSource(r'''
-class A {}
-class B extends A {
-  operator +(B b) {}
-}
-f(var a) {
-  if(a is A) {
-    a + 1;
-  }
-}''');
-    await computeAnalysisResult(source);
-    assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]);
-  }
-
-  test_undefinedOperator_indexBoth_inSubtype() async {
-    Source source = addSource(r'''
-class A {}
-class B extends A {
-  operator [](int index) {}
-}
-f(var a) {
-  if(a is A) {
-    a[0]++;
-  }
-}''');
-    await computeAnalysisResult(source);
-    assertErrors(source, [
-      StaticTypeWarningCode.UNDEFINED_OPERATOR,
-      StaticTypeWarningCode.UNDEFINED_OPERATOR,
-    ]);
-  }
-
-  test_undefinedOperator_indexGetter_inSubtype() async {
-    Source source = addSource(r'''
-class A {}
-class B extends A {
-  operator [](int index) {}
-}
-f(var a) {
-  if(a is A) {
-    a[0];
-  }
-}''');
-    await computeAnalysisResult(source);
-    assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]);
-  }
-
-  test_undefinedOperator_indexSetter_inSubtype() async {
-    Source source = addSource(r'''
-class A {}
-class B extends A {
-  operator []=(i, v) {}
-}
-f(var a) {
-  if(a is A) {
-    a[0] = 1;
-  }
-}''');
-    await computeAnalysisResult(source);
-    assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]);
-  }
-
-  test_undefinedOperator_postfixExpression() async {
-    Source source = addSource(r'''
-class A {}
-class B extends A {
-  operator +(B b) {return new B();}
-}
-f(var a) {
-  if(a is A) {
-    a++;
-  }
-}''');
-    await computeAnalysisResult(source);
-    assertNoErrors(source);
-  }
-
-  test_undefinedOperator_prefixExpression() async {
-    Source source = addSource(r'''
-class A {}
-class B extends A {
-  operator +(B b) {return new B();}
-}
-f(var a) {
-  if(a is A) {
-    ++a;
-  }
-}''');
-    await computeAnalysisResult(source);
-    assertNoErrors(source);
-  }
-
-  test_undefinedSetter_inSubtype() async {
-    Source source = addSource(r'''
-class A {}
-class B extends A {
-  set b(x) {}
-}
-f(var a) {
-  if (a is A) {
-    a.b = 0;
-  }
-}''');
-    await computeAnalysisResult(source);
-    assertErrors(source, [StaticTypeWarningCode.UNDEFINED_SETTER]);
-  }
-
-  test_unnecessaryNoSuchMethod_blockBody_notReturnStatement() async {
-    Source source = addSource(r'''
-class A {
-  noSuchMethod(x) => super.noSuchMethod(x);
-}
-class B extends A {
-  mmm();
-  noSuchMethod(y) {
-    print(y);
-  }
-}''');
-    await computeAnalysisResult(source);
-    assertNoErrors(source);
-    verify([source]);
-  }
-
-  test_unnecessaryNoSuchMethod_blockBody_notSingleStatement() async {
-    Source source = addSource(r'''
-class A {
-  noSuchMethod(x) => super.noSuchMethod(x);
-}
-class B extends A {
-  mmm();
-  noSuchMethod(y) {
-    print(y);
-    return super.noSuchMethod(y);
-  }
-}''');
-    await computeAnalysisResult(source);
-    assertNoErrors(source);
-    verify([source]);
-  }
-
-  test_unnecessaryNoSuchMethod_expressionBody_notNoSuchMethod() async {
-    Source source = addSource(r'''
-class A {
-  noSuchMethod(x) => super.noSuchMethod(x);
-}
-class B extends A {
-  mmm();
-  noSuchMethod(y) => super.hashCode;
-}''');
-    await computeAnalysisResult(source);
-    assertNoErrors(source);
-    verify([source]);
-  }
-
-  test_unnecessaryNoSuchMethod_expressionBody_notSuper() async {
-    Source source = addSource(r'''
-class A {
-  noSuchMethod(x) => super.noSuchMethod(x);
-}
-class B extends A {
-  mmm();
-  noSuchMethod(y) => 42;
-}''');
-    await computeAnalysisResult(source);
-    assertNoErrors(source);
-    verify([source]);
-  }
 }
 
 class PubSuggestionCodeTest extends ResolverTestCase {
diff --git a/pkg/analyzer/test/src/dart/resolution/resolution.dart b/pkg/analyzer/test/src/dart/resolution/resolution.dart
index ea69268..be8eb31 100644
--- a/pkg/analyzer/test/src/dart/resolution/resolution.dart
+++ b/pkg/analyzer/test/src/dart/resolution/resolution.dart
@@ -144,6 +144,10 @@
     expect(element.enclosingElement, expectedEnclosing);
   }
 
+  bool get enableUnusedLocalVariable => false;
+
+  bool get enableUnusedElement => false;
+
   /**
    * Assert that the number of error codes in reported [errors] matches the
    * number of [expected] error codes. The order of errors is ignored.
@@ -153,11 +157,15 @@
     var errorListener = new GatheringErrorListener();
     for (AnalysisError error in result.errors) {
       ErrorCode errorCode = error.errorCode;
-      if (errorCode == HintCode.UNUSED_CATCH_CLAUSE ||
-          errorCode == HintCode.UNUSED_CATCH_STACK ||
-          errorCode == HintCode.UNUSED_ELEMENT ||
-          errorCode == HintCode.UNUSED_FIELD ||
-          errorCode == HintCode.UNUSED_LOCAL_VARIABLE) {
+      if (!enableUnusedElement &&
+          (errorCode == HintCode.UNUSED_ELEMENT ||
+              errorCode == HintCode.UNUSED_FIELD)) {
+        continue;
+      }
+      if (!enableUnusedLocalVariable &&
+          (errorCode == HintCode.UNUSED_CATCH_CLAUSE ||
+              errorCode == HintCode.UNUSED_CATCH_STACK ||
+              errorCode == HintCode.UNUSED_LOCAL_VARIABLE)) {
         continue;
       }
       errorListener.onError(error);
diff --git a/pkg/analyzer/test/src/diagnostics/test_all.dart b/pkg/analyzer/test/src/diagnostics/test_all.dart
index d868804..5deb7f2 100644
--- a/pkg/analyzer/test/src/diagnostics/test_all.dart
+++ b/pkg/analyzer/test/src/diagnostics/test_all.dart
@@ -15,11 +15,26 @@
 import 'invalid_override_different_default_values_positional_test.dart'
     as invalid_override_different_default_values_positional;
 import 'invalid_required_param_test.dart' as invalid_required_param;
-import 'undefined_getter.dart' as undefined_getter;
+import 'top_level_instance_getter_test.dart' as top_level_instance_getter;
+import 'top_level_instance_method_test.dart' as top_level_instance_method;
+import 'type_check_is_not_null_test.dart' as type_check_is_not_null;
+import 'type_check_is_null_test.dart' as type_check_is_null;
+import 'undefined_getter_test.dart' as undefined_getter;
+import 'undefined_hidden_name_test.dart' as undefined_hidden_name;
+import 'undefined_operator_test.dart' as undefined_operator;
+import 'undefined_setter_test.dart' as undefined_setter;
+import 'undefined_shown_name_test.dart' as undefined_shown_name;
 import 'unnecessary_cast_test.dart' as unnecessary_cast;
+import 'unnecessary_no_such_method_test.dart' as unnecessary_no_such_method;
+import 'unnecessary_type_check_false_test.dart' as unnecessary_type_check_false;
+import 'unnecessary_type_check_true_test.dart' as unnecessary_type_check_true;
+import 'unused_catch_clause_test.dart' as unused_catch_clause;
+import 'unused_catch_stack_test.dart' as unused_catch_stack;
+import 'unused_element_test.dart' as unused_element;
 import 'unused_field_test.dart' as unused_field;
 import 'unused_import_test.dart' as unused_import;
 import 'unused_label_test.dart' as unused_label;
+import 'unused_local_variable_test.dart' as unused_local_variable;
 import 'unused_shown_name_test.dart' as unused_shown_name;
 import 'use_of_void_result_test.dart' as use_of_void_result;
 
@@ -34,11 +49,26 @@
     invalid_override_different_default_values_named.main();
     invalid_override_different_default_values_positional.main();
     invalid_required_param.main();
+    top_level_instance_getter.main();
+    top_level_instance_method.main();
+    type_check_is_not_null.main();
+    type_check_is_null.main();
     undefined_getter.main();
+    undefined_hidden_name.main();
+    undefined_operator.main();
+    undefined_setter.main();
+    undefined_shown_name.main();
     unnecessary_cast.main();
+    unnecessary_no_such_method.main();
+    unnecessary_type_check_false.main();
+    unnecessary_type_check_true.main();
+    unused_catch_clause.main();
+    unused_catch_stack.main();
+    unused_element.main();
     unused_field.main();
     unused_import.main();
     unused_label.main();
+    unused_local_variable.main();
     unused_shown_name.main();
     use_of_void_result.main();
   }, name: 'diagnostics');
diff --git a/pkg/analyzer/test/src/diagnostics/top_level_instance_getter_test.dart b/pkg/analyzer/test/src/diagnostics/top_level_instance_getter_test.dart
new file mode 100644
index 0000000..dae29d6
--- /dev/null
+++ b/pkg/analyzer/test/src/diagnostics/top_level_instance_getter_test.dart
@@ -0,0 +1,434 @@
+// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'package:analyzer/dart/ast/ast.dart';
+import 'package:analyzer/src/error/codes.dart';
+import 'package:test/test.dart';
+import 'package:test_reflective_loader/test_reflective_loader.dart';
+
+import '../dart/resolution/driver_resolution.dart';
+
+main() {
+  defineReflectiveSuite(() {
+    defineReflectiveTests(TopLevelInstanceGetterTest);
+  });
+}
+
+@reflectiveTest
+class TopLevelInstanceGetterTest extends DriverResolutionTest {
+  test_call() async {
+    await assertNoErrorsInCode('''
+class A {
+  int Function() get g => () => 0;
+}
+var a = new A();
+var b = a.g();
+''');
+    TopLevelVariableDeclaration b = result.unit.declarations[2];
+    expect(b.variables.variables[0].declaredElement.type.toString(), 'int');
+  }
+
+  test_field() async {
+    await assertNoErrorsInCode('''
+class A {
+  int g;
+}
+var b = new A().g;
+''');
+    TopLevelVariableDeclaration b = result.unit.declarations[1];
+    expect(b.variables.variables[0].declaredElement.type.toString(), 'int');
+  }
+
+  test_field_call() async {
+    await assertNoErrorsInCode('''
+class A {
+  int Function() g;
+}
+var a = new A();
+var b = a.g();
+''');
+    TopLevelVariableDeclaration b = result.unit.declarations[2];
+    expect(b.variables.variables[0].declaredElement.type.toString(), 'int');
+  }
+
+  test_field_prefixedIdentifier() async {
+    await assertNoErrorsInCode('''
+class A {
+  int g;
+}
+var a = new A();
+var b = a.g;
+''');
+    TopLevelVariableDeclaration b = result.unit.declarations[2];
+    expect(b.variables.variables[0].declaredElement.type.toString(), 'int');
+  }
+
+  test_getter() async {
+    await assertNoErrorsInCode('''
+class A {
+  int get g => 0;
+}
+var b = new A().g;
+''');
+    TopLevelVariableDeclaration b = result.unit.declarations[1];
+    expect(b.variables.variables[0].declaredElement.type.toString(), 'int');
+  }
+
+  test_implicitlyTyped() async {
+    await assertErrorsInCode('''
+class A {
+  get g => 0;
+}
+var b = new A().g;
+''', [StrongModeCode.TOP_LEVEL_INSTANCE_GETTER]);
+  }
+
+  test_implicitlyTyped_call() async {
+    await assertErrorsInCode('''
+class A {
+  get g => () => 0;
+}
+var a = new A();
+var b = a.g();
+''', [StrongModeCode.TOP_LEVEL_INSTANCE_GETTER]);
+  }
+
+  test_implicitlyTyped_field() async {
+    await assertErrorsInCode('''
+class A {
+  var g = 0;
+}
+var b = new A().g;
+''', [StrongModeCode.TOP_LEVEL_INSTANCE_GETTER]);
+  }
+
+  test_implicitlyTyped_field_call() async {
+    await assertErrorsInCode('''
+class A {
+  var g = () => 0;
+}
+var a = new A();
+var b = a.g();
+''', [StrongModeCode.TOP_LEVEL_INSTANCE_GETTER]);
+  }
+
+  test_implicitlyTyped_field_prefixedIdentifier() async {
+    await assertErrorsInCode('''
+class A {
+  var g = 0;
+}
+var a = new A();
+var b = a.g;
+''', [StrongModeCode.TOP_LEVEL_INSTANCE_GETTER]);
+  }
+
+  test_implicitlyTyped_fn() async {
+    // The reference to a.x triggers TOP_LEVEL_INSTANCE_GETTER because f is
+    // generic, so the type of a.x might affect the type of b.
+    await assertErrorsInCode('''
+class A {
+  var x = 0;
+}
+int f<T>(x) => 0;
+var a = new A();
+var b = f(a.x);
+''', [StrongModeCode.TOP_LEVEL_INSTANCE_GETTER]);
+  }
+
+  test_implicitlyTyped_fn_explicit_type_params() async {
+    // The reference to a.x does not trigger TOP_LEVEL_INSTANCE_GETTER because
+    // it can't possibly affect the type of b.
+    await assertNoErrorsInCode('''
+class A {
+  var x = 0;
+}
+int f<T>(x) => 0;
+var a = new A();
+var b = f<int>(a.x);
+''');
+  }
+
+  test_implicitlyTyped_fn_not_generic() async {
+    // The reference to a.x does not trigger TOP_LEVEL_INSTANCE_GETTER because
+    // it can't possibly affect the type of b.
+    await assertNoErrorsInCode('''
+class A {
+  var x = 0;
+}
+int f(x) => 0;
+var a = new A();
+var b = f(a.x);
+''');
+  }
+
+  test_implicitlyTyped_indexExpression() async {
+    // The reference to a.x does not trigger TOP_LEVEL_INSTANCE_GETTER because
+    // it can't possibly affect the type of b.
+    await assertNoErrorsInCode('''
+class A {
+  var x = 0;
+  int operator[](int value) => 0;
+}
+var a = new A();
+var b = a[a.x];
+''');
+  }
+
+  test_implicitlyTyped_invoke() async {
+    // The reference to a.x triggers TOP_LEVEL_INSTANCE_GETTER because the
+    // closure is generic, so the type of a.x might affect the type of b.
+    await assertErrorsInCode('''
+class A {
+  var x = 0;
+}
+var a = new A();
+var b = (<T>(y) => 0)(a.x);
+''', [StrongModeCode.TOP_LEVEL_INSTANCE_GETTER]);
+  }
+
+  test_implicitlyTyped_invoke_explicit_type_params() async {
+    // The reference to a.x does not trigger TOP_LEVEL_INSTANCE_GETTER because
+    // it can't possibly affect the type of b.
+    await assertNoErrorsInCode('''
+class A {
+  var x = 0;
+}
+var a = new A();
+var b = (<T>(y) => 0)<int>(a.x);
+''');
+  }
+
+  test_implicitlyTyped_invoke_not_generic() async {
+    // The reference to a.x does not trigger TOP_LEVEL_INSTANCE_GETTER because
+    // it can't possibly affect the type of b.
+    await assertNoErrorsInCode('''
+class A {
+  var x = 0;
+}
+var a = new A();
+var b = ((y) => 0)(a.x);
+''');
+  }
+
+  test_implicitlyTyped_method() async {
+    // The reference to a.x triggers TOP_LEVEL_INSTANCE_GETTER because f is
+    // generic, so the type of a.x might affect the type of b.
+    await assertErrorsInCode('''
+class A {
+  var x = 0;
+  int f<T>(int x) => 0;
+}
+var a = new A();
+var b = a.f(a.x);
+''', [StrongModeCode.TOP_LEVEL_INSTANCE_GETTER]);
+  }
+
+  test_implicitlyTyped_method_explicit_type_params() async {
+    // The reference to a.x does not trigger TOP_LEVEL_INSTANCE_GETTER because
+    // it can't possibly affect the type of b.
+    await assertNoErrorsInCode('''
+class A {
+  var x = 0;
+  int f<T>(x) => 0;
+}
+var a = new A();
+var b = a.f<int>(a.x);
+''');
+  }
+
+  test_implicitlyTyped_method_not_generic() async {
+    // The reference to a.x does not trigger TOP_LEVEL_INSTANCE_GETTER because
+    // it can't possibly affect the type of b.
+    await assertNoErrorsInCode('''
+class A {
+  var x = 0;
+  int f(x) => 0;
+}
+var a = new A();
+var b = a.f(a.x);
+''');
+  }
+
+  test_implicitlyTyped_new() async {
+    // The reference to a.x triggers TOP_LEVEL_INSTANCE_GETTER because B is
+    // generic, so the type of a.x might affect the type of b.
+    await assertErrorsInCode('''
+class A {
+  var x = 0;
+}
+class B<T> {
+  B(x);
+}
+var a = new A();
+var b = new B(a.x);
+''', [StrongModeCode.TOP_LEVEL_INSTANCE_GETTER]);
+  }
+
+  test_implicitlyTyped_new_explicit_type_params() async {
+    // The reference to a.x does not trigger TOP_LEVEL_INSTANCE_GETTER because
+    // it can't possibly affect the type of b.
+    await assertNoErrorsInCode('''
+class A {
+  var x = 0;
+}
+class B<T> {
+  B(x);
+}
+var a = new A();
+var b = new B<int>(a.x);
+''');
+  }
+
+  test_implicitlyTyped_new_explicit_type_params_named() async {
+    // The reference to a.x does not trigger TOP_LEVEL_INSTANCE_GETTER because
+    // it can't possibly affect the type of b.
+    await assertNoErrorsInCode('''
+class A {
+  var x = 0;
+}
+class B<T> {
+  B.named(x);
+}
+var a = new A();
+var b = new B<int>.named(a.x);
+''');
+  }
+
+  test_implicitlyTyped_new_explicit_type_params_prefixed() async {
+    // The reference to a.x does not trigger TOP_LEVEL_INSTANCE_GETTER because
+    // it can't possibly affect the type of b.
+    newFile('/test/lib/lib1.dart', content: '''
+class B<T> {
+  B(x);
+}
+''');
+    await assertNoErrorsInCode('''
+import 'lib1.dart' as foo;
+class A {
+  var x = 0;
+}
+var a = new A();
+var b = new foo.B<int>(a.x);
+''');
+  }
+
+  test_implicitlyTyped_new_named() async {
+    // The reference to a.x triggers TOP_LEVEL_INSTANCE_GETTER because B is
+    // generic, so the type of a.x might affect the type of b.
+    await assertErrorsInCode('''
+class A {
+  var x = 0;
+}
+class B<T> {
+  B.named(x);
+}
+var a = new A();
+var b = new B.named(a.x);
+''', [StrongModeCode.TOP_LEVEL_INSTANCE_GETTER]);
+  }
+
+  test_implicitlyTyped_new_not_generic() async {
+    // The reference to a.x does not trigger TOP_LEVEL_INSTANCE_GETTER because
+    // it can't possibly affect the type of b.
+    await assertNoErrorsInCode('''
+class A {
+  var x = 0;
+}
+class B {
+  B(x);
+}
+var a = new A();
+var b = new B(a.x);
+''');
+  }
+
+  test_implicitlyTyped_new_not_generic_named() async {
+    // The reference to a.x does not trigger TOP_LEVEL_INSTANCE_GETTER because
+    // it can't possibly affect the type of b.
+    await assertNoErrorsInCode('''
+class A {
+  var x = 0;
+}
+class B {
+  B.named(x);
+}
+var a = new A();
+var b = new B.named(a.x);
+''');
+  }
+
+  test_implicitlyTyped_new_not_generic_prefixed() async {
+    newFile('/test/lib/lib1.dart', content: '''
+class B {
+  B(x);
+}
+''');
+    // The reference to a.x does not trigger TOP_LEVEL_INSTANCE_GETTER because
+    // it can't possibly affect the type of b.
+    await assertNoErrorsInCode('''
+import 'lib1.dart' as foo;
+class A {
+  var x = 0;
+}
+var a = new A();
+var b = new foo.B(a.x);
+''');
+  }
+
+  test_implicitlyTyped_new_prefixed() async {
+    newFile('/test/lib/lib1.dart', content: '''
+class B<T> {
+  B(x);
+}
+''');
+    // The reference to a.x triggers TOP_LEVEL_INSTANCE_GETTER because B is
+    // generic, so the type of a.x might affect the type of b.
+    await assertErrorsInCode('''
+import 'lib1.dart' as foo;
+class A {
+  var x = 0;
+}
+var a = new A();
+var b = new foo.B(a.x);
+''', [StrongModeCode.TOP_LEVEL_INSTANCE_GETTER]);
+  }
+
+  test_implicitlyTyped_prefixedIdentifier() async {
+    await assertErrorsInCode('''
+class A {
+  get g => 0;
+}
+var a = new A();
+var b = a.g;
+''', [StrongModeCode.TOP_LEVEL_INSTANCE_GETTER]);
+  }
+
+  test_implicitlyTyped_propertyAccessLhs() async {
+    // The reference to a.x triggers TOP_LEVEL_INSTANCE_GETTER because the type
+    // of a.x affects the lookup of y, which in turn affects the type of b.
+    await assertErrorsInCode('''
+class A {
+  var x = new B();
+  int operator[](int value) => 0;
+}
+class B {
+  int y;
+}
+var a = new A();
+var b = (a.x).y;
+''', [StrongModeCode.TOP_LEVEL_INSTANCE_GETTER]);
+  }
+
+  test_prefixedIdentifier() async {
+    await assertNoErrorsInCode('''
+class A {
+  int get g => 0;
+}
+var a = new A();
+var b = a.g;
+''');
+    TopLevelVariableDeclaration b = result.unit.declarations[2];
+    expect(b.variables.variables[0].declaredElement.type.toString(), 'int');
+  }
+}
diff --git a/pkg/analyzer/test/src/diagnostics/top_level_instance_method_test.dart b/pkg/analyzer/test/src/diagnostics/top_level_instance_method_test.dart
new file mode 100644
index 0000000..4e6dde5
--- /dev/null
+++ b/pkg/analyzer/test/src/diagnostics/top_level_instance_method_test.dart
@@ -0,0 +1,89 @@
+// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'package:analyzer/src/error/codes.dart';
+import 'package:test_reflective_loader/test_reflective_loader.dart';
+
+import '../dart/resolution/driver_resolution.dart';
+
+main() {
+  defineReflectiveSuite(() {
+    defineReflectiveTests(TopLevelInstanceMethodTest);
+  });
+}
+
+@reflectiveTest
+class TopLevelInstanceMethodTest extends DriverResolutionTest {
+  test_noParameter() async {
+    await assertErrorsInCode('''
+class A {
+  f() => 0;
+}
+var x = new A().f();
+''', [StrongModeCode.TOP_LEVEL_INSTANCE_METHOD]);
+  }
+
+  test_parameter() async {
+    await assertNoErrorsInCode('''
+class A {
+  int f(v) => 0;
+}
+var x = new A().f(0);
+''');
+  }
+
+  test_parameter_generic() async {
+    await assertErrorsInCode('''
+class A {
+  int f<T>(v) => 0;
+}
+var x = new A().f(0);
+''', [StrongModeCode.TOP_LEVEL_INSTANCE_METHOD]);
+  }
+
+  test_parameter_generic_explicit() async {
+    await assertNoErrorsInCode('''
+class A {
+  int f<T>(v) => 0;
+}
+var x = new A().f<int>(0);
+''');
+  }
+
+  test_static() async {
+    await assertNoErrorsInCode('''
+class A {
+  static f() => 0;
+}
+var x = A.f();
+''');
+  }
+
+  test_tearOff() async {
+    await assertErrorsInCode('''
+class A {
+  f() => 0;
+}
+var x = new A().f;
+''', [StrongModeCode.TOP_LEVEL_INSTANCE_METHOD]);
+  }
+
+  test_tearOff_parameter() async {
+    await assertErrorsInCode('''
+class A {
+  int f(v) => 0;
+}
+var x = new A().f;
+''', [StrongModeCode.TOP_LEVEL_INSTANCE_METHOD]);
+  }
+
+  test_tearoff_static() async {
+    await assertNoErrorsInCode('''
+class A {
+  static f() => 0;
+}
+var x = A.f;
+''');
+  }
+}
diff --git a/pkg/analyzer/test/src/diagnostics/type_check_is_not_null_test.dart b/pkg/analyzer/test/src/diagnostics/type_check_is_not_null_test.dart
new file mode 100644
index 0000000..a5d66af
--- /dev/null
+++ b/pkg/analyzer/test/src/diagnostics/type_check_is_not_null_test.dart
@@ -0,0 +1,25 @@
+// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'package:analyzer/src/error/codes.dart';
+import 'package:test_reflective_loader/test_reflective_loader.dart';
+
+import '../dart/resolution/driver_resolution.dart';
+
+main() {
+  defineReflectiveSuite(() {
+    defineReflectiveTests(TypeCheckIsNotNullTest);
+  });
+}
+
+@reflectiveTest
+class TypeCheckIsNotNullTest extends DriverResolutionTest {
+  test_not_Null() async {
+    await assertErrorsInCode(r'''
+bool m(i) {
+  return i is! Null;
+}
+''', [HintCode.TYPE_CHECK_IS_NOT_NULL]);
+  }
+}
diff --git a/pkg/analyzer/test/src/diagnostics/type_check_is_null_test.dart b/pkg/analyzer/test/src/diagnostics/type_check_is_null_test.dart
new file mode 100644
index 0000000..4f50661
--- /dev/null
+++ b/pkg/analyzer/test/src/diagnostics/type_check_is_null_test.dart
@@ -0,0 +1,25 @@
+// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'package:analyzer/src/error/codes.dart';
+import 'package:test_reflective_loader/test_reflective_loader.dart';
+
+import '../dart/resolution/driver_resolution.dart';
+
+main() {
+  defineReflectiveSuite(() {
+    defineReflectiveTests(TypeCheckIsNullTest);
+  });
+}
+
+@reflectiveTest
+class TypeCheckIsNullTest extends DriverResolutionTest {
+  test_is_Null() async {
+    await assertErrorsInCode(r'''
+bool m(i) {
+  return i is Null;
+}
+''', [HintCode.TYPE_CHECK_IS_NULL]);
+  }
+}
diff --git a/pkg/analyzer/test/src/diagnostics/undefined_getter.dart b/pkg/analyzer/test/src/diagnostics/undefined_getter_test.dart
similarity index 94%
rename from pkg/analyzer/test/src/diagnostics/undefined_getter.dart
rename to pkg/analyzer/test/src/diagnostics/undefined_getter_test.dart
index 69c298b..e0f34b6 100644
--- a/pkg/analyzer/test/src/diagnostics/undefined_getter.dart
+++ b/pkg/analyzer/test/src/diagnostics/undefined_getter_test.dart
@@ -22,8 +22,7 @@
 
   test_ifStatement_notPromoted() async {
     await assertErrorsInCode('''
-f() {
-  int x;
+f(int x) {
   if (x is String) {
     x.length;
   }
@@ -33,8 +32,7 @@
 
   test_ifStatement_promoted() async {
     await assertNoErrorsInCode('''
-f() {
-  Object x;
+f(Object x) {
   if (x is String) {
     x.length;
   }
@@ -64,8 +62,7 @@
 
   test_ifElement_inList_notPromoted() async {
     await assertErrorsInCode('''
-f() {
-  int x;
+f(int x) {
   return [if (x is String) x.length];
 }
 ''', [StaticTypeWarningCode.UNDEFINED_GETTER], verify: false);
@@ -73,8 +70,7 @@
 
   test_ifElement_inList_promoted() async {
     await assertNoErrorsInCode('''
-f() {
-  Object x;
+f(Object x) {
   return [if (x is String) x.length];
 }
 ''');
@@ -82,8 +78,7 @@
 
   test_ifElement_inMap_notPromoted() async {
     await assertErrorsInCode('''
-f() {
-  int x;
+f(int x) {
   return {if (x is String) x : x.length};
 }
 ''', [StaticTypeWarningCode.UNDEFINED_GETTER], verify: false);
@@ -91,8 +86,7 @@
 
   test_ifElement_inMap_promoted() async {
     await assertNoErrorsInCode('''
-f() {
-  Object x;
+f(Object x) {
   return {if (x is String) x : x.length};
 }
 ''');
@@ -100,8 +94,7 @@
 
   test_ifElement_inSet_notPromoted() async {
     await assertErrorsInCode('''
-f() {
-  int x;
+f(int x) {
   return {if (x is String) x.length};
 }
 ''', [StaticTypeWarningCode.UNDEFINED_GETTER], verify: false);
@@ -109,8 +102,7 @@
 
   test_ifElement_inSet_promoted() async {
     await assertNoErrorsInCode('''
-f() {
-  Object x;
+f(Object x) {
   return {if (x is String) x.length};
 }
 ''');
diff --git a/pkg/analyzer/test/src/diagnostics/undefined_hidden_name_test.dart b/pkg/analyzer/test/src/diagnostics/undefined_hidden_name_test.dart
new file mode 100644
index 0000000..3391749
--- /dev/null
+++ b/pkg/analyzer/test/src/diagnostics/undefined_hidden_name_test.dart
@@ -0,0 +1,31 @@
+// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'package:analyzer/src/error/codes.dart';
+import 'package:test_reflective_loader/test_reflective_loader.dart';
+
+import '../dart/resolution/driver_resolution.dart';
+
+main() {
+  defineReflectiveSuite(() {
+    defineReflectiveTests(UndefinedHiddenNameTest);
+  });
+}
+
+@reflectiveTest
+class UndefinedHiddenNameTest extends DriverResolutionTest {
+  test_export() async {
+    newFile('/test/lib/lib1.dart');
+    await assertErrorsInCode(r'''
+export 'lib1.dart' hide a;
+''', [HintCode.UNDEFINED_HIDDEN_NAME]);
+  }
+
+  test_import() async {
+    newFile('/test/lib/lib1.dart');
+    await assertErrorsInCode(r'''
+import 'lib1.dart' hide a;
+''', [HintCode.UNUSED_IMPORT, HintCode.UNDEFINED_HIDDEN_NAME]);
+  }
+}
diff --git a/pkg/analyzer/test/src/diagnostics/undefined_operator_test.dart b/pkg/analyzer/test/src/diagnostics/undefined_operator_test.dart
new file mode 100644
index 0000000..b05ef9b
--- /dev/null
+++ b/pkg/analyzer/test/src/diagnostics/undefined_operator_test.dart
@@ -0,0 +1,173 @@
+// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'package:analyzer/src/error/codes.dart';
+import 'package:test_reflective_loader/test_reflective_loader.dart';
+
+import '../dart/resolution/driver_resolution.dart';
+
+main() {
+  defineReflectiveSuite(() {
+    defineReflectiveTests(UndefinedOperatorTest);
+  });
+}
+
+@reflectiveTest
+class UndefinedOperatorTest extends DriverResolutionTest {
+  test_binaryExpression() async {
+    await assertErrorsInCode(r'''
+class A {}
+f(var a) {
+  if (a is A) {
+    a + 1;
+  }
+}
+''', [StaticTypeWarningCode.UNDEFINED_OPERATOR]);
+  }
+
+  test_binaryExpression_inSubtype() async {
+    await assertErrorsInCode(r'''
+class A {}
+class B extends A {
+  operator +(B b) {}
+}
+f(var a) {
+  if (a is A) {
+    a + 1;
+  }
+}
+''', [StaticTypeWarningCode.UNDEFINED_OPERATOR]);
+  }
+
+  test_indexBoth() async {
+    await assertErrorsInCode(r'''
+class A {}
+f(var a) {
+  if (a is A) {
+    a[0]++;
+  }
+}
+''', [
+      StaticTypeWarningCode.UNDEFINED_OPERATOR,
+      StaticTypeWarningCode.UNDEFINED_OPERATOR,
+    ]);
+  }
+
+  test_indexBoth_inSubtype() async {
+    await assertErrorsInCode(r'''
+class A {}
+class B extends A {
+  operator [](int index) {}
+}
+f(var a) {
+  if (a is A) {
+    a[0]++;
+  }
+}
+''', [
+      StaticTypeWarningCode.UNDEFINED_OPERATOR,
+      StaticTypeWarningCode.UNDEFINED_OPERATOR,
+    ]);
+  }
+
+  test_indexGetter() async {
+    await assertErrorsInCode(r'''
+class A {}
+f(var a) {
+  if (a is A) {
+    a[0];
+  }
+}
+''', [StaticTypeWarningCode.UNDEFINED_OPERATOR]);
+  }
+
+  test_indexGetter_inSubtype() async {
+    await assertErrorsInCode(r'''
+class A {}
+class B extends A {
+  operator [](int index) {}
+}
+f(var a) {
+  if (a is A) {
+    a[0];
+  }
+}
+''', [StaticTypeWarningCode.UNDEFINED_OPERATOR]);
+  }
+
+  test_indexSetter() async {
+    await assertErrorsInCode(r'''
+class A {}
+f(var a) {
+  if (a is A) {
+    a[0] = 1;
+  }
+}
+''', [StaticTypeWarningCode.UNDEFINED_OPERATOR]);
+  }
+
+  test_indexSetter_inSubtype() async {
+    await assertErrorsInCode(r'''
+class A {}
+class B extends A {
+  operator []=(i, v) {}
+}
+f(var a) {
+  if (a is A) {
+    a[0] = 1;
+  }
+}
+''', [StaticTypeWarningCode.UNDEFINED_OPERATOR]);
+  }
+
+  test_postfixExpression() async {
+    await assertNoErrorsInCode(r'''
+class A {}
+f(var a) {
+  if (a is A) {
+    a++;
+  }
+}
+''');
+  }
+
+  test_postfixExpression_inSubtype() async {
+    await assertNoErrorsInCode(r'''
+class A {}
+class B extends A {
+  operator +(B b) {return new B();}
+}
+f(var a) {
+  if (a is A) {
+    a++;
+  }
+}
+''');
+  }
+
+  test_prefixExpression() async {
+    await assertNoErrorsInCode(r'''
+class A {}
+f(var a) {
+  if (a is A) {
+    ++a;
+  }
+}
+''');
+  }
+
+  test_prefixExpression_inSubtype() async {
+    await assertNoErrorsInCode(r'''
+class A {}
+class B extends A {
+  operator +(B b) {return new B();}
+}
+f(var a) {
+  if (a is A) {
+    ++a;
+  }
+}
+''');
+  }
+}
diff --git a/pkg/analyzer/test/src/diagnostics/undefined_setter_test.dart b/pkg/analyzer/test/src/diagnostics/undefined_setter_test.dart
new file mode 100644
index 0000000..fd9bafd
--- /dev/null
+++ b/pkg/analyzer/test/src/diagnostics/undefined_setter_test.dart
@@ -0,0 +1,42 @@
+// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'package:analyzer/src/error/codes.dart';
+import 'package:test_reflective_loader/test_reflective_loader.dart';
+
+import '../dart/resolution/driver_resolution.dart';
+
+main() {
+  defineReflectiveSuite(() {
+    defineReflectiveTests(UndefinedSetterTest);
+  });
+}
+
+@reflectiveTest
+class UndefinedSetterTest extends DriverResolutionTest {
+  test_inSubtype() async {
+    await assertErrorsInCode(r'''
+class A {}
+class B extends A {
+  set b(x) {}
+}
+f(var a) {
+  if (a is A) {
+    a.b = 0;
+  }
+}
+''', [StaticTypeWarningCode.UNDEFINED_SETTER]);
+  }
+
+  test_inType() async {
+    await assertErrorsInCode(r'''
+class A {}
+f(var a) {
+  if(a is A) {
+    a.m = 0;
+  }
+}
+''', [StaticTypeWarningCode.UNDEFINED_SETTER]);
+  }
+}
diff --git a/pkg/analyzer/test/src/diagnostics/undefined_shown_name_test.dart b/pkg/analyzer/test/src/diagnostics/undefined_shown_name_test.dart
new file mode 100644
index 0000000..9bbc57a
--- /dev/null
+++ b/pkg/analyzer/test/src/diagnostics/undefined_shown_name_test.dart
@@ -0,0 +1,31 @@
+// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'package:analyzer/src/error/codes.dart';
+import 'package:test_reflective_loader/test_reflective_loader.dart';
+
+import '../dart/resolution/driver_resolution.dart';
+
+main() {
+  defineReflectiveSuite(() {
+    defineReflectiveTests(UndefinedShownNameTest);
+  });
+}
+
+@reflectiveTest
+class UndefinedShownNameTest extends DriverResolutionTest {
+  test_export() async {
+    newFile('/test/lib/lib1.dart');
+    await assertErrorsInCode(r'''
+export 'lib1.dart' show a;
+''', [HintCode.UNDEFINED_SHOWN_NAME]);
+  }
+
+  test_import() async {
+    newFile('/test/lib/lib1.dart');
+    await assertErrorsInCode(r'''
+import 'lib1.dart' show a;
+''', [HintCode.UNUSED_IMPORT, HintCode.UNDEFINED_SHOWN_NAME]);
+  }
+}
diff --git a/pkg/analyzer/test/src/diagnostics/unnecessary_no_such_method_test.dart b/pkg/analyzer/test/src/diagnostics/unnecessary_no_such_method_test.dart
new file mode 100644
index 0000000..e6f36ad
--- /dev/null
+++ b/pkg/analyzer/test/src/diagnostics/unnecessary_no_such_method_test.dart
@@ -0,0 +1,96 @@
+// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'package:analyzer/src/dart/error/hint_codes.dart';
+import 'package:test_reflective_loader/test_reflective_loader.dart';
+
+import '../dart/resolution/driver_resolution.dart';
+
+main() {
+  defineReflectiveSuite(() {
+    defineReflectiveTests(UnnecessaryNoSuchMethodTest);
+  });
+}
+
+@reflectiveTest
+class UnnecessaryNoSuchMethodTest extends DriverResolutionTest {
+  test_blockBody() async {
+    await assertErrorsInCode(r'''
+class A {
+  noSuchMethod(x) => super.noSuchMethod(x);
+}
+class B extends A {
+  mmm();
+  noSuchMethod(y) {
+    return super.noSuchMethod(y);
+  }
+}
+''', [HintCode.UNNECESSARY_NO_SUCH_METHOD]);
+  }
+
+  test_blockBody_notReturnStatement() async {
+    await assertNoErrorsInCode(r'''
+class A {
+  noSuchMethod(x) => super.noSuchMethod(x);
+}
+class B extends A {
+  mmm();
+  noSuchMethod(y) {
+    print(y);
+  }
+}
+''');
+  }
+
+  test_blockBody_notSingleStatement() async {
+    await assertNoErrorsInCode(r'''
+class A {
+  noSuchMethod(x) => super.noSuchMethod(x);
+}
+class B extends A {
+  mmm();
+  noSuchMethod(y) {
+    print(y);
+    return super.noSuchMethod(y);
+  }
+}
+''');
+  }
+
+  test_expressionBody() async {
+    await assertErrorsInCode(r'''
+class A {
+  noSuchMethod(x) => super.noSuchMethod(x);
+}
+class B extends A {
+  mmm();
+  noSuchMethod(y) => super.noSuchMethod(y);
+}
+''', [HintCode.UNNECESSARY_NO_SUCH_METHOD]);
+  }
+
+  test_expressionBody_notNoSuchMethod() async {
+    await assertNoErrorsInCode(r'''
+class A {
+  noSuchMethod(x) => super.noSuchMethod(x);
+}
+class B extends A {
+  mmm();
+  noSuchMethod(y) => super.hashCode;
+}
+''');
+  }
+
+  test_expressionBody_notSuper() async {
+    await assertNoErrorsInCode(r'''
+class A {
+  noSuchMethod(x) => super.noSuchMethod(x);
+}
+class B extends A {
+  mmm();
+  noSuchMethod(y) => 42;
+}
+''');
+  }
+}
diff --git a/pkg/analyzer/test/src/diagnostics/unnecessary_type_check_false_test.dart b/pkg/analyzer/test/src/diagnostics/unnecessary_type_check_false_test.dart
new file mode 100644
index 0000000..6b48d25
--- /dev/null
+++ b/pkg/analyzer/test/src/diagnostics/unnecessary_type_check_false_test.dart
@@ -0,0 +1,39 @@
+// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'package:analyzer/src/dart/error/hint_codes.dart';
+import 'package:test_reflective_loader/test_reflective_loader.dart';
+
+import '../dart/resolution/driver_resolution.dart';
+
+main() {
+  defineReflectiveSuite(() {
+    defineReflectiveTests(UnnecessaryTypeCheckFalseTest);
+  });
+}
+
+@reflectiveTest
+class UnnecessaryTypeCheckFalseTest extends DriverResolutionTest {
+  test_null_not_Null() async {
+    await assertErrorsInCode(r'''
+bool b = null is! Null;
+''', [HintCode.UNNECESSARY_TYPE_CHECK_FALSE]);
+  }
+
+  test_type_not_dynamic() async {
+    await assertErrorsInCode(r'''
+m(i) {
+  bool b = i is! dynamic;
+}
+''', [HintCode.UNNECESSARY_TYPE_CHECK_FALSE]);
+  }
+
+  test_type_not_object() async {
+    await assertErrorsInCode(r'''
+m(i) {
+  bool b = i is! Object;
+}
+''', [HintCode.UNNECESSARY_TYPE_CHECK_FALSE]);
+  }
+}
diff --git a/pkg/analyzer/test/src/diagnostics/unnecessary_type_check_true_test.dart b/pkg/analyzer/test/src/diagnostics/unnecessary_type_check_true_test.dart
new file mode 100644
index 0000000..44e96ea
--- /dev/null
+++ b/pkg/analyzer/test/src/diagnostics/unnecessary_type_check_true_test.dart
@@ -0,0 +1,39 @@
+// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'package:analyzer/src/dart/error/hint_codes.dart';
+import 'package:test_reflective_loader/test_reflective_loader.dart';
+
+import '../dart/resolution/driver_resolution.dart';
+
+main() {
+  defineReflectiveSuite(() {
+    defineReflectiveTests(UnnecessaryTypeCheckTrueTest);
+  });
+}
+
+@reflectiveTest
+class UnnecessaryTypeCheckTrueTest extends DriverResolutionTest {
+  test_null_is_Null() async {
+    await assertErrorsInCode(r'''
+bool b = null is Null;
+''', [HintCode.UNNECESSARY_TYPE_CHECK_TRUE]);
+  }
+
+  test_type_is_dynamic() async {
+    await assertErrorsInCode(r'''
+m(i) {
+  bool b = i is dynamic;
+}
+''', [HintCode.UNNECESSARY_TYPE_CHECK_TRUE]);
+  }
+
+  test_type_is_object() async {
+    await assertErrorsInCode(r'''
+m(i) {
+  bool b = i is Object;
+}
+''', [HintCode.UNNECESSARY_TYPE_CHECK_TRUE]);
+  }
+}
diff --git a/pkg/analyzer/test/src/diagnostics/unused_catch_clause_test.dart b/pkg/analyzer/test/src/diagnostics/unused_catch_clause_test.dart
new file mode 100644
index 0000000..841f0df
--- /dev/null
+++ b/pkg/analyzer/test/src/diagnostics/unused_catch_clause_test.dart
@@ -0,0 +1,62 @@
+// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'package:analyzer/src/dart/error/hint_codes.dart';
+import 'package:test_reflective_loader/test_reflective_loader.dart';
+
+import '../dart/resolution/driver_resolution.dart';
+
+main() {
+  defineReflectiveSuite(() {
+    defineReflectiveTests(UnusedCatchClauseTest);
+  });
+}
+
+@reflectiveTest
+class UnusedCatchClauseTest extends DriverResolutionTest {
+  @override
+  bool get enableUnusedLocalVariable => true;
+
+  test_on_unusedException() async {
+    await assertErrorsInCode(r'''
+main() {
+  try {
+  } on String catch (exception) {
+  }
+}
+''', [HintCode.UNUSED_CATCH_CLAUSE]);
+  }
+
+  test_on_usedException() async {
+    await assertNoErrorsInCode(r'''
+main() {
+  try {
+  } on String catch (exception) {
+    print(exception);
+  }
+}
+''');
+  }
+
+  test_unusedException() async {
+    await assertNoErrorsInCode(r'''
+main() {
+  try {
+  } catch (exception) {
+  }
+}
+''');
+  }
+
+  test_usedException() async {
+    await assertNoErrorsInCode(r'''
+main() {
+  try {
+  } catch (exception) {
+    print(exception);
+  }
+}
+''');
+  }
+}
diff --git a/pkg/analyzer/test/src/diagnostics/unused_catch_stack_test.dart b/pkg/analyzer/test/src/diagnostics/unused_catch_stack_test.dart
new file mode 100644
index 0000000..0a7330b
--- /dev/null
+++ b/pkg/analyzer/test/src/diagnostics/unused_catch_stack_test.dart
@@ -0,0 +1,66 @@
+// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'package:analyzer/src/dart/error/hint_codes.dart';
+import 'package:test_reflective_loader/test_reflective_loader.dart';
+
+import '../../generated/resolver_test_case.dart';
+
+main() {
+  defineReflectiveSuite(() {
+    defineReflectiveTests(UnusedCatchStackTest);
+  });
+}
+
+@reflectiveTest
+class UnusedCatchStackTest extends ResolverTestCase {
+  @override
+  bool get enableNewAnalysisDriver => true;
+
+  test_on_unusedStack() async {
+    enableUnusedLocalVariable = true;
+    await assertErrorsInCode(r'''
+main() {
+  try {
+  } on String catch (exception, stackTrace) {
+  }
+}
+''', [HintCode.UNUSED_CATCH_STACK]);
+  }
+
+  test_on_usedStack() async {
+    enableUnusedLocalVariable = true;
+    await assertNoErrorsInCode(r'''
+main() {
+  try {
+  } on String catch (exception, stackTrace) {
+    print(stackTrace);
+  }
+}
+''');
+  }
+
+  test_unusedStack() async {
+    enableUnusedLocalVariable = true;
+    await assertErrorsInCode(r'''
+main() {
+  try {
+  } catch (exception, stackTrace) {
+  }
+}
+''', [HintCode.UNUSED_CATCH_STACK]);
+  }
+
+  test_usedStack() async {
+    enableUnusedLocalVariable = true;
+    await assertNoErrorsInCode(r'''
+main() {
+  try {
+  } catch (exception, stackTrace) {
+    print(stackTrace);
+  }
+}
+''');
+  }
+}
diff --git a/pkg/analyzer/test/src/diagnostics/unused_element_test.dart b/pkg/analyzer/test/src/diagnostics/unused_element_test.dart
new file mode 100644
index 0000000..871023a
--- /dev/null
+++ b/pkg/analyzer/test/src/diagnostics/unused_element_test.dart
@@ -0,0 +1,577 @@
+// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'package:analyzer/src/dart/error/hint_codes.dart';
+import 'package:test_reflective_loader/test_reflective_loader.dart';
+
+import '../dart/resolution/driver_resolution.dart';
+
+main() {
+  defineReflectiveSuite(() {
+    defineReflectiveTests(UnusedElementTest);
+  });
+}
+
+@reflectiveTest
+class UnusedElementTest extends DriverResolutionTest {
+  @override
+  bool get enableUnusedElement => true;
+
+  test_class_isUsed_extends() async {
+    await assertNoErrorsInCode(r'''
+class _A {}
+class B extends _A {}
+''');
+  }
+
+  test_class_isUsed_fieldDeclaration() async {
+    await assertNoErrorsInCode(r'''
+class Foo {
+  _Bar x;
+}
+
+class _Bar {
+}
+''');
+  }
+
+  test_class_isUsed_implements() async {
+    await assertNoErrorsInCode(r'''
+class _A {}
+class B implements _A {}
+''');
+  }
+
+  test_class_isUsed_instanceCreation() async {
+    await assertNoErrorsInCode(r'''
+class _A {}
+main() {
+  new _A();
+}
+''');
+  }
+
+  test_class_isUsed_staticFieldAccess() async {
+    await assertNoErrorsInCode(r'''
+class _A {
+  static const F = 42;
+}
+main() {
+  _A.F;
+}
+''');
+  }
+
+  test_class_isUsed_staticMethodInvocation() async {
+    await assertNoErrorsInCode(r'''
+class _A {
+  static m() {}
+}
+main() {
+  _A.m();
+}
+''');
+  }
+
+  test_class_isUsed_typeArgument() async {
+    await assertNoErrorsInCode(r'''
+class _A {}
+main() {
+  var v = new List<_A>();
+  print(v);
+}
+''');
+  }
+
+  test_class_notUsed_inClassMember() async {
+    await assertErrorsInCode(r'''
+class _A {
+  static staticMethod() {
+    new _A();
+  }
+  instanceMethod() {
+    new _A();
+  }
+}
+''', [HintCode.UNUSED_ELEMENT]);
+  }
+
+  test_class_notUsed_inConstructorName() async {
+    await assertErrorsInCode(r'''
+class _A {
+  _A() {}
+  _A.named() {}
+}
+''', [HintCode.UNUSED_ELEMENT]);
+  }
+
+  test_class_notUsed_isExpression() async {
+    await assertErrorsInCode(r'''
+class _A {}
+main(p) {
+  if (p is _A) {
+  }
+}
+''', [HintCode.UNUSED_ELEMENT]);
+  }
+
+  test_class_notUsed_noReference() async {
+    await assertErrorsInCode(r'''
+class _A {}
+main() {
+}
+''', [HintCode.UNUSED_ELEMENT]);
+  }
+
+  test_class_notUsed_variableDeclaration() async {
+    await assertErrorsInCode(r'''
+class _A {}
+main() {
+  _A v;
+  print(v);
+}
+print(x) {}
+''', [HintCode.UNUSED_ELEMENT]);
+  }
+
+  test_enum_isUsed_fieldReference() async {
+    await assertNoErrorsInCode(r'''
+enum _MyEnum {A, B, C}
+main() {
+  print(_MyEnum.B);
+}
+''');
+  }
+
+  test_enum_notUsed_noReference() async {
+    await assertErrorsInCode(r'''
+enum _MyEnum {A, B, C}
+main() {
+}
+''', [HintCode.UNUSED_ELEMENT]);
+  }
+
+  test_functionLocal_isUsed_closure() async {
+    await assertNoErrorsInCode(r'''
+main() {
+  print(() {});
+}
+print(x) {}
+''');
+  }
+
+  test_functionLocal_isUsed_invocation() async {
+    await assertNoErrorsInCode(r'''
+main() {
+  f() {}
+  f();
+}
+''');
+  }
+
+  test_functionLocal_isUsed_reference() async {
+    await assertNoErrorsInCode(r'''
+main() {
+  f() {}
+  print(f);
+}
+print(x) {}
+''');
+  }
+
+  test_functionLocal_notUsed_noReference() async {
+    await assertErrorsInCode(r'''
+main() {
+  f() {}
+}
+''', [HintCode.UNUSED_ELEMENT]);
+  }
+
+  test_functionLocal_notUsed_referenceFromItself() async {
+    await assertErrorsInCode(r'''
+main() {
+  _f(int p) {
+    _f(p - 1);
+  }
+}
+''', [HintCode.UNUSED_ELEMENT]);
+  }
+
+  test_functionTop_isUsed_invocation() async {
+    await assertNoErrorsInCode(r'''
+_f() {}
+main() {
+  _f();
+}
+''');
+  }
+
+  test_functionTop_isUsed_reference() async {
+    await assertNoErrorsInCode(r'''
+_f() {}
+main() {
+  print(_f);
+}
+print(x) {}
+''');
+  }
+
+  test_functionTop_notUsed_noReference() async {
+    await assertErrorsInCode(r'''
+_f() {}
+main() {
+}
+''', [HintCode.UNUSED_ELEMENT]);
+  }
+
+  test_functionTop_notUsed_referenceFromItself() async {
+    await assertErrorsInCode(r'''
+_f(int p) {
+  _f(p - 1);
+}
+main() {
+}
+''', [HintCode.UNUSED_ELEMENT]);
+  }
+
+  test_functionTypeAlias_isUsed_isExpression() async {
+    await assertNoErrorsInCode(r'''
+typedef _F(a, b);
+main(f) {
+  if (f is _F) {
+    print('F');
+  }
+}
+''');
+  }
+
+  test_functionTypeAlias_isUsed_reference() async {
+    await assertNoErrorsInCode(r'''
+typedef _F(a, b);
+main(_F f) {
+}
+''');
+  }
+
+  test_functionTypeAlias_isUsed_typeArgument() async {
+    await assertNoErrorsInCode(r'''
+typedef _F(a, b);
+main() {
+  var v = new List<_F>();
+  print(v);
+}
+''');
+  }
+
+  test_functionTypeAlias_isUsed_variableDeclaration() async {
+    await assertNoErrorsInCode(r'''
+typedef _F(a, b);
+class A {
+  _F f;
+}
+''');
+  }
+
+  test_functionTypeAlias_notUsed_noReference() async {
+    await assertErrorsInCode(r'''
+typedef _F(a, b);
+main() {
+}
+''', [HintCode.UNUSED_ELEMENT]);
+  }
+
+  test_getter_isUsed_invocation_implicitThis() async {
+    await assertNoErrorsInCode(r'''
+class A {
+  get _g => null;
+  useGetter() {
+    var v = _g;
+  }
+}
+''');
+  }
+
+  test_getter_isUsed_invocation_PrefixedIdentifier() async {
+    await assertNoErrorsInCode(r'''
+class A {
+  get _g => null;
+}
+main(A a) {
+  var v = a._g;
+}
+''');
+  }
+
+  test_getter_isUsed_invocation_PropertyAccess() async {
+    await assertNoErrorsInCode(r'''
+class A {
+  get _g => null;
+}
+main() {
+  var v = new A()._g;
+}
+''');
+  }
+
+  test_getter_notUsed_noReference() async {
+    await assertErrorsInCode(r'''
+class A {
+  get _g => null;
+}
+''', [HintCode.UNUSED_ELEMENT]);
+  }
+
+  test_getter_notUsed_referenceFromItself() async {
+    await assertErrorsInCode(r'''
+class A {
+  get _g {
+    return _g;
+  }
+}
+''', [HintCode.UNUSED_ELEMENT]);
+  }
+
+  test_method_isUsed_hasReference_implicitThis() async {
+    await assertNoErrorsInCode(r'''
+class A {
+  _m() {}
+  useMethod() {
+    print(_m);
+  }
+}
+print(x) {}
+''');
+  }
+
+  test_method_isUsed_hasReference_implicitThis_subclass() async {
+    await assertNoErrorsInCode(r'''
+class A {
+  _m() {}
+  useMethod() {
+    print(_m);
+  }
+}
+class B extends A {
+  _m() {}
+}
+print(x) {}
+''');
+  }
+
+  test_method_isUsed_hasReference_PrefixedIdentifier() async {
+    await assertNoErrorsInCode(r'''
+class A {
+  _m() {}
+}
+main(A a) {
+  a._m;
+}
+''');
+  }
+
+  test_method_isUsed_hasReference_PropertyAccess() async {
+    await assertNoErrorsInCode(r'''
+class A {
+  _m() {}
+}
+main() {
+  new A()._m;
+}
+''');
+  }
+
+  test_method_isUsed_invocation_implicitThis() async {
+    await assertNoErrorsInCode(r'''
+class A {
+  _m() {}
+  useMethod() {
+    _m();
+  }
+}
+''');
+  }
+
+  test_method_isUsed_invocation_implicitThis_subclass() async {
+    await assertNoErrorsInCode(r'''
+class A {
+  _m() {}
+  useMethod() {
+    _m();
+  }
+}
+class B extends A {
+  _m() {}
+}
+''');
+  }
+
+  test_method_isUsed_invocation_MemberElement() async {
+    await assertNoErrorsInCode(r'''
+class A<T> {
+  _m(T t) {}
+}
+main(A<int> a) {
+  a._m(0);
+}
+''');
+  }
+
+  test_method_isUsed_invocation_propagated() async {
+    await assertNoErrorsInCode(r'''
+class A {
+  _m() {}
+}
+main() {
+  var a = new A();
+  a._m();
+}
+''');
+  }
+
+  test_method_isUsed_invocation_static() async {
+    await assertNoErrorsInCode(r'''
+class A {
+  _m() {}
+}
+main() {
+  A a = new A();
+  a._m();
+}
+''');
+  }
+
+  test_method_isUsed_invocation_subclass() async {
+    await assertNoErrorsInCode(r'''
+class A {
+  _m() {}
+}
+class B extends A {
+  _m() {}
+}
+main(A a) {
+  a._m();
+}
+''');
+  }
+
+  test_method_isUsed_notPrivate() async {
+    await assertNoErrorsInCode(r'''
+class A {
+  m() {}
+}
+main() {
+}
+''');
+  }
+
+  test_method_isUsed_staticInvocation() async {
+    await assertNoErrorsInCode(r'''
+class A {
+  static _m() {}
+}
+main() {
+  A._m();
+}
+''');
+  }
+
+  test_method_notUsed_noReference() async {
+    await assertErrorsInCode(r'''
+class A {
+  static _m() {}
+}
+''', [HintCode.UNUSED_ELEMENT]);
+  }
+
+  test_method_notUsed_referenceFromItself() async {
+    await assertErrorsInCode(r'''
+class A {
+  static _m(int p) {
+    _m(p - 1);
+  }
+}
+''', [HintCode.UNUSED_ELEMENT]);
+  }
+
+  test_setter_isUsed_invocation_implicitThis() async {
+    await assertNoErrorsInCode(r'''
+class A {
+  set _s(x) {}
+  useSetter() {
+    _s = 42;
+  }
+}
+''');
+  }
+
+  test_setter_isUsed_invocation_PrefixedIdentifier() async {
+    await assertNoErrorsInCode(r'''
+class A {
+  set _s(x) {}
+}
+main(A a) {
+  a._s = 42;
+}
+''');
+  }
+
+  test_setter_isUsed_invocation_PropertyAccess() async {
+    await assertNoErrorsInCode(r'''
+class A {
+  set _s(x) {}
+}
+main() {
+  new A()._s = 42;
+}
+''');
+  }
+
+  test_setter_notUsed_noReference() async {
+    await assertErrorsInCode(r'''
+class A {
+  set _s(x) {}
+}
+''', [HintCode.UNUSED_ELEMENT]);
+  }
+
+  test_setter_notUsed_referenceFromItself() async {
+    await assertErrorsInCode(r'''
+class A {
+  set _s(int x) {
+    if (x > 5) {
+      _s = x - 1;
+    }
+  }
+}
+''', [HintCode.UNUSED_ELEMENT]);
+  }
+
+  test_topLevelVariable_isUsed() async {
+    await assertNoErrorsInCode(r'''
+int _a = 1;
+main() {
+  _a;
+}
+''');
+  }
+
+  test_topLevelVariable_isUsed_plusPlus() async {
+    await assertNoErrorsInCode(r'''
+int _a = 0;
+main() {
+  var b = _a++;
+  b;
+}
+''');
+  }
+
+  test_topLevelVariable_notUsed() async {
+    await assertErrorsInCode(r'''
+int _a = 1;
+main() {
+  _a = 2;
+}
+''', [HintCode.UNUSED_ELEMENT]);
+  }
+}
diff --git a/pkg/analyzer/test/src/diagnostics/unused_local_variable_test.dart b/pkg/analyzer/test/src/diagnostics/unused_local_variable_test.dart
new file mode 100644
index 0000000..ee12d06
--- /dev/null
+++ b/pkg/analyzer/test/src/diagnostics/unused_local_variable_test.dart
@@ -0,0 +1,132 @@
+// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'package:analyzer/src/dart/error/hint_codes.dart';
+import 'package:test_reflective_loader/test_reflective_loader.dart';
+
+import '../../generated/resolver_test_case.dart';
+
+main() {
+  defineReflectiveSuite(() {
+    defineReflectiveTests(UnusedLocalVariableTest);
+  });
+}
+
+@reflectiveTest
+class UnusedLocalVariableTest extends ResolverTestCase {
+  @override
+  bool get enableNewAnalysisDriver => true;
+
+  test_inFor_underscore_ignored() async {
+    enableUnusedLocalVariable = true;
+    await assertNoErrorsInCode(r'''
+main() {
+  for (var _ in [1,2,3]) {
+    for (var __ in [4,5,6]) {
+      // do something
+    }
+  }
+}
+''');
+  }
+
+  test_inFunction() async {
+    enableUnusedLocalVariable = true;
+    await assertErrorsInCode(r'''
+main() {
+  var v = 1;
+  v = 2;
+}
+''', [HintCode.UNUSED_LOCAL_VARIABLE]);
+  }
+
+  test_inMethod() async {
+    enableUnusedLocalVariable = true;
+    await assertErrorsInCode(r'''
+class A {
+  foo() {
+    var v = 1;
+    v = 2;
+  }
+}
+''', [HintCode.UNUSED_LOCAL_VARIABLE]);
+  }
+
+  test_isInvoked() async {
+    enableUnusedLocalVariable = true;
+    await assertNoErrorsInCode(r'''
+typedef Foo();
+main() {
+  Foo foo;
+  foo();
+}
+''');
+  }
+
+  test_isNullAssigned() async {
+    enableUnusedLocalVariable = true;
+    await assertNoErrorsInCode(r'''
+typedef Foo();
+main() {
+  var v;
+  v ??= doSomething();
+}
+doSomething() => 42;
+''');
+  }
+
+  test_isRead_notUsed_compoundAssign() async {
+    enableUnusedLocalVariable = true;
+    await assertErrorsInCode(r'''
+main() {
+  var v = 1;
+  v += 2;
+}
+''', [HintCode.UNUSED_LOCAL_VARIABLE]);
+  }
+
+  test_isRead_notUsed_postfixExpr() async {
+    enableUnusedLocalVariable = true;
+    await assertErrorsInCode(r'''
+main() {
+  var v = 1;
+  v++;
+}
+''', [HintCode.UNUSED_LOCAL_VARIABLE]);
+  }
+
+  test_isRead_notUsed_prefixExpr() async {
+    enableUnusedLocalVariable = true;
+    await assertErrorsInCode(r'''
+main() {
+  var v = 1;
+  ++v;
+}
+''', [HintCode.UNUSED_LOCAL_VARIABLE]);
+  }
+
+  test_isRead_usedArgument() async {
+    enableUnusedLocalVariable = true;
+    await assertNoErrorsInCode(r'''
+main() {
+  var v = 1;
+  print(++v);
+}
+print(x) {}
+''');
+  }
+
+  test_isRead_usedInvocationTarget() async {
+    enableUnusedLocalVariable = true;
+    await assertNoErrorsInCode(r'''
+class A {
+  foo() {}
+}
+main() {
+  var a = new A();
+  a.foo();
+}
+''');
+  }
+}