anchor.diff:      ]);
     }
   
  +  test_invocation_generic() async {
  +    await assertErrorsInCode('''
  +class A<T> {
  +  m(T t) {}
  +}
  +f(A<String> a) {
  +  a.m(1);
  +}''', [
  +      error(CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, 50, 1),
  +    ]);
  +  }
  +
  +  test_invocation_named() async {
  +    await assertErrorsInCode('''
  +f({String p = ''}) {}
  +main() {
  +  f(p: 42);
  +}''', [
  +      error(CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, 35, 5),
  +    ]);
  +  }
  +
  +  test_invocation_optional() async {
  +    await assertErrorsInCode('''
  +f([String p = '']) {}
  +main() {
  +  f(42);
  +}''', [
  +      error(CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, 35, 2),
  +    ]);
  +  }
  +
  +  test_invocation_required() async {
  +    await assertErrorsInCode('''
  +f(String p) {}
  +main() {
  +  f(42);
  +}''', [
  +      error(CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, 28, 2),
  +    ]);
  +  }
  +
  +  test_invocation_typedef_generic() async {
  +    await assertErrorsInCode('''
  +typedef A<T>(T p);
  +f(A<int> a) {
  +  a('1');
  +}''', [
  +      error(CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, 37, 3),
  +    ]);
  +  }
  +
  +  test_invocation_typedef_local() async {
  +    await assertErrorsInCode('''
  +typedef A(int p);
  +A getA() => throw '';
  +main() {
  +  A a = getA();
  +  a('1');
  +}''', [
  +      error(CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, 69, 3),
  +    ]);
  +  }
  +
  +  test_invocation_typedef_parameter() async {
  +    await assertErrorsInCode('''
  +typedef A(int p);
  +f(A a) {
  +  a('1');
  +}''', [
  +      error(CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, 31, 3),
  +    ]);
  +  }
  +
  +  test_new_generic() async {
  +    await assertErrorsInCode('''
  +class A<T> {
  +  A(T p) {}
  +}
  +main() {
  +  new A<String>(42);
  +}''', [
  +      error(CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, 52, 2),
  +    ]);
  +  }
  +
  +  test_new_optional() async {
  +    await assertErrorsInCode('''
  +class A {
  +  A([String p = '']) {}
  +}
  +main() {
  +  new A(42);
  +}''', [
  +      error(CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, 53, 2),
  +    ]);
  +  }
  +
  +  test_new_required() async {
  +    await assertErrorsInCode('''
  +class A {
  +  A(String p) {}
  +}
  +main() {
  +  new A(42);
  +}''', [
  +      error(CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, 46, 2),
  +    ]);
  +  }
  +
  +  @failingTest
  +  test_tearOff_required() async {
  +    await assertErrorsInCode('''
  +class C {
  +  Object/*=T*/ f/*<T>*/(Object/*=T*/ x) => x;
  +}
  +g(C c) {
  +  var h = c.f/*<int>*/;
  +  print(h('s'));
  +}
  +''', [
  +      error(CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, 99, 1),
  +    ]);
  +  }
  +}
  +
  +@reflectiveTest
  +class ArgumentTypeNotAssignableWithoutNullSafetyTest
  +    extends PubPackageResolutionTest
  +    with WithoutNullSafetyMixin, ArgumentTypeNotAssignableTestCases {
     test_invocation_functionTypes_optional() async {
       await assertErrorsInCode('''
   void acceptFunOptBool(void funNumOptBool([bool b])) {}
  
positive.code:       error(CompileTimeErrorCode.INVALID_CAST_METHOD, 125, 9),
      ]);
    }
  
    test_invocation_generic() async {
      await assertErrorsInCode('''
  class A<T> {
    m(T t) {}
  }
  f(A<String> a) {
    a.m(1);
  }''', [
        error(CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, 50, 1),
      ]);
    }
  
    test_invocation_named() async {
      await assertErrorsInCode('''
  f({String p = ''}) {}
  main() {
    f(p: 42);
  }''', [
        error(CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, 35, 5),
      ]);
    }
  
    test_invocation_optional() async {
      await assertErrorsInCode('''
  f([String p = '']) {}
  main() {
    f(42);
  }''', [
        error(CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, 35, 2),
      ]);
    }
  
    test_invocation_required() async {
      await assertErrorsInCode('''
  f(String p) {}
  main() {
    f(42);
  }''', [
        error(CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, 28, 2),
      ]);
    }
  
    test_invocation_typedef_generic() async {
      await assertErrorsInCode('''
  typedef A<T>(T p);
  f(A<int> a) {
    a('1');
  }''', [
        error(CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, 37, 3),
      ]);
    }
  
    test_invocation_typedef_local() async {
      await assertErrorsInCode('''
  typedef A(int p);
  A getA() => throw '';
  main() {
    A a = getA();
    a('1');
  }''', [
        error(CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, 69, 3),
      ]);
    }
  
    test_invocation_typedef_parameter() async {
      await assertErrorsInCode('''
  typedef A(int p);
  f(A a) {
    a('1');
  }''', [
        error(CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, 31, 3),
      ]);
    }
  
    test_new_generic() async {
      await assertErrorsInCode('''
  class A<T> {
    A(T p) {}
  }
  main() {
    new A<String>(42);
  }''', [
        error(CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, 52, 2),
      ]);
    }
  
    test_new_optional() async {
      await assertErrorsInCode('''
  class A {
    A([String p = '']) {}
  }
  main() {
    new A(42);
  }''', [
        error(CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, 53, 2),
      ]);
    }
  
    test_new_required() async {
      await assertErrorsInCode('''
  class A {
    A(String p) {}
  }
  main() {
    new A(42);
  }''', [
        error(CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, 46, 2),
      ]);
    }
  
    @failingTest
    test_tearOff_required() async {
      await assertErrorsInCode('''
  class C {
    Object/*=T*/ f/*<T>*/(Object/*=T*/ x) => x;
  }
  g(C c) {
    var h = c.f/*<int>*/;
    print(h('s'));
  }
  ''', [
        error(CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, 99, 1),
      ]);
    }
  }
  
  @reflectiveTest
  class ArgumentTypeNotAssignableWithNullSafetyTest
      extends ArgumentTypeNotAssignableTest with WithNullSafetyMixin {
    test_binary_eqEq_covariantParameterType() async {
      await assertErrorsInCode(r'''
  class A {
    bool operator==(covariant A other) => false;
  }
  
  void f(A a, A? aq) {
    a == 0;
    aq == 1;
    aq == aq;
    aq == null;
  }
  ''', [
        error(CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, 88, 1),
        error(CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, 99, 1),
      ]);
    }
  
    test_downcast() async {
      await assertErrorsInCode(r'''
  m() {
    num y = 1;
    n(y);
  }
  n(int x) {}
  ''', [
        error(CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, 23, 1),
      ]);
    }
  
    @failingTest
    test_downcast_nullableNonNullable() async {
      await assertErrorsInCode(r'''
  m() {
    int? y;
    n(y);
  }
  n(int x) {}
  ''', [
        error(CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, 24, 1),
      ]);
    }
  
    test_dynamicCast() async {
      await assertNoErrorsInCode(r'''
  m() {
    dynamic i;
    n(i);
  }
  n(int i) {}
  ''');
    }
  
    @failingTest
    @override
    test_invocation_functionTypes_optional() async {
      // The test is currently generating an error where none is expected.
      await super.test_invocation_functionTypes_optional();
    }
  
    @override
    test_invocation_functionTypes_optional_method() async {
      await assertErrorsInCode('''
  void acceptFunOptBool(void funOptBool([bool b])) {}
  class C {
    static void funBool(bool b) {}
  }
  main() {
    acceptFunOptBool(C.funBool);
  }''', [
        error(CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, 125, 9),
      ]);
    }
  }
  
negative.code: main() {
    defineReflectiveSuite(() {
      defineReflectiveTests(ArgumentTypeNotAssignableTest);
      defineReflectiveTests(ArgumentTypeNotAssignableWithoutNullSafetyTest);
    });
  }
  
  @reflectiveTest
  class ArgumentTypeNotAssignableTest extends PubPackageResolutionTest
      with ArgumentTypeNotAssignableTestCases {
    test_annotation_namedConstructor_generic() async {
      await assertErrorsInCode('''
  class A<T> {
    const A.fromInt(T p);
  }
  @A<int>.fromInt('0')
  main() {
  }''', [
        error(CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, 55, 3),
      ]);
    }
  
    test_binary_eqEq_covariantParameterType() async {
      await assertErrorsInCode(r'''
  class A {
    bool operator==(covariant A other) => false;
  }
  
  void f(A a, A? aq) {
    a == 0;
    aq == 1;
    aq == aq;
    aq == null;
  }
  ''', [
        error(CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, 88, 1),
        error(CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, 99, 1),
      ]);
    }
  
    test_downcast() async {
      await assertErrorsInCode(r'''
  m() {
    num y = 1;
    n(y);
  }
  n(int x) {}
  ''', [
        error(CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, 23, 1),
      ]);
    }
  
    test_downcast_nullableNonNullable() async {
      await assertErrorsInCode(r'''
  m() {
    int? y;
    n(y);
  }
  n(int x) {}
  ''', [
        error(CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, 20, 1),
      ]);
    }
  
    test_dynamicCast() async {
      await assertNoErrorsInCode(r'''
  m() {
    dynamic i;
    n(i);
  }
  n(int i) {}
  ''');
    }
  
    test_invocation_functionTypes_optional() async {
      await assertErrorsInCode('''
  void acceptFunOptBool(void funNumOptBool([bool b])) {}
  void funBool(bool b) {}
  main() {
    acceptFunOptBool(funBool);
  }''', [
        error(CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, 107, 7),
      ]);
    }
  
    test_invocation_functionTypes_optional_method() async {
      await assertErrorsInCode('''
  void acceptFunOptBool(void funOptBool([bool b])) {}
  class C {
    static void funBool(bool b) {}
  }
  main() {
    acceptFunOptBool(C.funBool);
  }''', [
        error(CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, 125, 9),
      ]);
    }
  }
  
  mixin ArgumentTypeNotAssignableTestCases on PubPackageResolutionTest {
    test_ambiguousClassName() async {
      // See dartbug.com/19624
      newFile('$testPackageLibPath/lib2.dart', content: '''
  