Version 2.13.0-161.0.dev

Merge commit '86c5085565f90fe661290d5b2feebba9c1a7df8f' into 'dev'
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/make_return_type_nullable.dart b/pkg/analysis_server/lib/src/services/correction/dart/make_return_type_nullable.dart
index 5fdea07..fa90e5f 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/make_return_type_nullable.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/make_return_type_nullable.dart
@@ -22,18 +22,12 @@
       return;
     }
     var body = node.thisOrAncestorOfType<FunctionBody>();
-    TypeAnnotation returnType;
-    var function = body.parent;
-    if (function is FunctionExpression) {
-      function = function.parent;
-    }
-    if (function is MethodDeclaration) {
-      returnType = function.returnType;
-    } else if (function is FunctionDeclaration) {
-      returnType = function.returnType;
-    } else {
+
+    var returnType = _getReturnTypeNode(body);
+    if (returnType == null) {
       return;
     }
+
     if (body.isAsynchronous || body.isGenerator) {
       if (returnType is! NamedType) {
         return null;
@@ -60,4 +54,17 @@
 
   /// Return an instance of this class. Used as a tear-off in `FixProcessor`.
   static MakeReturnTypeNullable newInstance() => MakeReturnTypeNullable();
+
+  static TypeAnnotation _getReturnTypeNode(FunctionBody body) {
+    var function = body.parent;
+    if (function is FunctionExpression) {
+      function = function.parent;
+    }
+    if (function is MethodDeclaration) {
+      return function.returnType;
+    } else if (function is FunctionDeclaration) {
+      return function.returnType;
+    }
+    return null;
+  }
 }
diff --git a/pkg/analysis_server/test/src/services/correction/fix/make_return_type_nullable_test.dart b/pkg/analysis_server/test/src/services/correction/fix/make_return_type_nullable_test.dart
index e661f34..7e976e7 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/make_return_type_nullable_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/make_return_type_nullable_test.dart
@@ -133,6 +133,21 @@
 ''');
   }
 
+  Future<void> test_method_sync_inherited() async {
+    await resolveTestCode('''
+abstract class A {
+  String m(String? s);
+}
+
+class B extends A {
+  m(String? s) {
+    return s;
+  }
+}
+''');
+    await assertNoFix();
+  }
+
   Future<void> test_returnTypeHasTypeArguments() async {
     await resolveTestCode('''
 List<String> f() {
diff --git a/pkg/analyzer/lib/src/dart/resolver/property_element_resolver.dart b/pkg/analyzer/lib/src/dart/resolver/property_element_resolver.dart
index 23fcd9b..36abe1c 100644
--- a/pkg/analyzer/lib/src/dart/resolver/property_element_resolver.dart
+++ b/pkg/analyzer/lib/src/dart/resolver/property_element_resolver.dart
@@ -8,7 +8,6 @@
 import 'package:analyzer/error/error.dart';
 import 'package:analyzer/error/listener.dart';
 import 'package:analyzer/src/dart/ast/extensions.dart';
-import 'package:analyzer/src/dart/element/element.dart';
 import 'package:analyzer/src/dart/element/inheritance_manager3.dart';
 import 'package:analyzer/src/dart/element/type.dart';
 import 'package:analyzer/src/dart/element/type_system.dart';
@@ -677,15 +676,11 @@
             inherited: true,
           );
           if (writeElement != null) {
-            var receiverSuperClass =
-                targetType.element.supertype!.element as ClassElementImpl;
-            if (!receiverSuperClass.hasNoSuchMethod) {
-              _errorReporter.reportErrorForNode(
-                CompileTimeErrorCode.ABSTRACT_SUPER_MEMBER_REFERENCE,
-                propertyName,
-                [writeElement.kind.displayName, propertyName.name],
-              );
-            }
+            _errorReporter.reportErrorForNode(
+              CompileTimeErrorCode.ABSTRACT_SUPER_MEMBER_REFERENCE,
+              propertyName,
+              [writeElement.kind.displayName, propertyName.name],
+            );
           } else {
             _errorReporter.reportErrorForNode(
               CompileTimeErrorCode.UNDEFINED_SUPER_SETTER,
diff --git a/pkg/analyzer/test/src/diagnostics/abstract_super_member_reference_test.dart b/pkg/analyzer/test/src/diagnostics/abstract_super_member_reference_test.dart
index 4a78f7c..762abe6 100644
--- a/pkg/analyzer/test/src/diagnostics/abstract_super_member_reference_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/abstract_super_member_reference_test.dart
@@ -378,6 +378,34 @@
     }
   }
 
+  test_propertyAccess_setter_mixin_implements() async {
+    await assertErrorsInCode(r'''
+class A {
+  set foo(int _) {}
+}
+
+mixin M implements A {
+  void bar() {
+    super.foo = 0;
+  }
+}
+''', [
+      error(CompileTimeErrorCode.ABSTRACT_SUPER_MEMBER_REFERENCE, 81, 3),
+    ]);
+
+    assertSuperExpression(findNode.super_('super.foo'));
+
+    assertAssignment(
+      findNode.assignment('foo ='),
+      readElement: null,
+      readType: null,
+      writeElement: findElement.setter('foo'),
+      writeType: 'int',
+      operatorElement: null,
+      type: 'int',
+    );
+  }
+
   test_propertyAccess_setter_mixinHasNoSuchMethod() async {
     await assertErrorsInCode('''
 class A {
diff --git a/pkg/analyzer/test/src/diagnostics/argument_type_not_assignable_test.dart b/pkg/analyzer/test/src/diagnostics/argument_type_not_assignable_test.dart
index 1ce8a4b..1225bc4 100644
--- a/pkg/analyzer/test/src/diagnostics/argument_type_not_assignable_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/argument_type_not_assignable_test.dart
@@ -11,13 +11,103 @@
 main() {
   defineReflectiveSuite(() {
     defineReflectiveTests(ArgumentTypeNotAssignableTest);
-    defineReflectiveTests(ArgumentTypeNotAssignableWithNullSafetyTest);
+    defineReflectiveTests(ArgumentTypeNotAssignableWithoutNullSafetyTest);
   });
 }
 
 @reflectiveTest
 class ArgumentTypeNotAssignableTest extends PubPackageResolutionTest
-    with WithoutNullSafetyMixin {
+    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: '''
@@ -290,30 +380,6 @@
     ]);
   }
 
-  test_invocation_functionTypes_optional() async {
-    await assertErrorsInCode('''
-void acceptFunOptBool(void funNumOptBool([bool b])) {}
-void funBool(bool b) {}
-main() {
-  acceptFunOptBool(funBool);
-}''', [
-      error(CompileTimeErrorCode.INVALID_CAST_FUNCTION, 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.INVALID_CAST_METHOD, 125, 9),
-    ]);
-  }
-
   test_invocation_generic() async {
     await assertErrorsInCode('''
 class A<T> {
@@ -441,69 +507,20 @@
 }
 
 @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
+class ArgumentTypeNotAssignableWithoutNullSafetyTest
+    extends PubPackageResolutionTest
+    with WithoutNullSafetyMixin, ArgumentTypeNotAssignableTestCases {
   test_invocation_functionTypes_optional() async {
-    // The test is currently generating an error where none is expected.
-    await super.test_invocation_functionTypes_optional();
+    await assertErrorsInCode('''
+void acceptFunOptBool(void funNumOptBool([bool b])) {}
+void funBool(bool b) {}
+main() {
+  acceptFunOptBool(funBool);
+}''', [
+      error(CompileTimeErrorCode.INVALID_CAST_FUNCTION, 107, 7),
+    ]);
   }
 
-  @override
   test_invocation_functionTypes_optional_method() async {
     await assertErrorsInCode('''
 void acceptFunOptBool(void funOptBool([bool b])) {}
@@ -513,7 +530,7 @@
 main() {
   acceptFunOptBool(C.funBool);
 }''', [
-      error(CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, 125, 9),
+      error(CompileTimeErrorCode.INVALID_CAST_METHOD, 125, 9),
     ]);
   }
 }
diff --git a/pkg/analyzer/test/src/diagnostics/invalid_annotation_from_deferred_library_test.dart b/pkg/analyzer/test/src/diagnostics/invalid_annotation_from_deferred_library_test.dart
index 88263a6..589f88c 100644
--- a/pkg/analyzer/test/src/diagnostics/invalid_annotation_from_deferred_library_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/invalid_annotation_from_deferred_library_test.dart
@@ -31,6 +31,22 @@
     ]);
   }
 
+  @FailingTest(reason: 'https://github.com/dart-lang/sdk/issues/45418')
+  test_constructor_argument() async {
+    newFile('$testPackageLibPath/lib1.dart', content: '''
+const x = 0;
+''');
+    await assertErrorsInCode('''
+library root;
+import 'lib1.dart' deferred as a;
+class C { const C(int i); }
+@C(a.x) main () {}
+''', [
+      error(
+          CompileTimeErrorCode.INVALID_ANNOTATION_FROM_DEFERRED_LIBRARY, 49, 3),
+    ]);
+  }
+
   test_from_deferred_library() async {
     newFile('$testPackageLibPath/lib1.dart', content: '''
 library lib1;
diff --git a/pkg/analyzer/test/src/diagnostics/type_annotation_deferred_class_test.dart b/pkg/analyzer/test/src/diagnostics/type_annotation_deferred_class_test.dart
index 1068226..c622fb0 100644
--- a/pkg/analyzer/test/src/diagnostics/type_annotation_deferred_class_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/type_annotation_deferred_class_test.dart
@@ -15,6 +15,20 @@
 
 @reflectiveTest
 class TypeAnnotationDeferredClassTest extends PubPackageResolutionTest {
+  test_annotation_typeArgument() async {
+    newFile('$testPackageLibPath/lib1.dart', content: '''
+class D {}
+''');
+    await assertErrorsInCode('''
+library root;
+import 'lib1.dart' deferred as a;
+class C<T> { const C(); }
+@C<a.D>() main () {}
+''', [
+      error(CompileTimeErrorCode.TYPE_ANNOTATION_DEFERRED_CLASS, 77, 3),
+    ]);
+  }
+
   test_asExpression() async {
     newFile('$testPackageLibPath/lib1.dart', content: '''
 library lib1;
diff --git a/tools/VERSION b/tools/VERSION
index 2c67925..34ef5ef 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
 MAJOR 2
 MINOR 13
 PATCH 0
-PRERELEASE 160
+PRERELEASE 161
 PRERELEASE_PATCH 0
\ No newline at end of file