anchor.diff:  ''');
     }
   
  -  test_function() async {
  -    await assertNoErrorsInCode(r'''
  -void f() {
  -  Function(Null) a = (String x) {};
  -  (a as Function(int))(3);
  -}
  -''');
  -  }
  -
  -  test_function2() async {
  -    await assertNoErrorsInCode(r'''
  -class A {}
  -
  -class B<T extends A> {
  -  void foo() {
  -    T Function(T) f;
  -    f as A Function(A);
  -  }
  +  test_function_toSubtype_viaParameter() async {
  +    await assertNoErrorsInCode(r'''
  +void f(void Function(int) a) {
  +  (a as void Function(num))(3);
  +}
  +''');
  +  }
  +
  +  test_function_toSubtype_viaReturnType() async {
  +    await assertNoErrorsInCode(r'''
  +void f(num Function() a) {
  +  (a as int Function())();
  +}
  +''');
  +  }
  +
  +  test_function_toSupertype_viaParameter() async {
  +    await assertErrorsInCode(r'''
  +void f(void Function(num) a) {
  +  (a as void Function(int))(3);
  +}
  +''', [
  +      error(HintCode.UNNECESSARY_CAST, 34, 23),
  +    ]);
  +  }
  +
  +  test_function_toSupertype_viaReturnType() async {
  +    await assertErrorsInCode(r'''
  +void f(int Function() a) {
  +  (a as num Function())();
  +}
  +''', [
  +      error(HintCode.UNNECESSARY_CAST, 30, 19),
  +    ]);
  +  }
  +
  +  test_function_toUnrelated() async {
  +    await assertNoErrorsInCode(r'''
  +void f(num Function(num) a) {
  +  (a as int Function(int))(3);
  +}
  +''');
  +  }
  +
  +  test_function_toUnrelated_generic() async {
  +    await assertNoErrorsInCode(r'''
  +void f<T extends num>(T Function(T) a) {
  +  (a as int Function(int))(3);
   }
   ''');
     }
  
positive.code: 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(UnnecessaryCastTest);
    });
  }
  
  
negative.code: ''');
    }
  }
  
  @reflectiveTest
  class UnnecessaryCastTestWithNullSafety extends UnnecessaryCastTest
      with WithNullSafetyMixin {}
  