Fix handling of named constructors in convert_to_super_parameters

Change-Id: If20d797cf8ad0c91d42e4d56e5cf7fecc1124e0d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/237200
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/convert_to_super_parameters.dart b/pkg/analysis_server/lib/src/services/correction/dart/convert_to_super_parameters.dart
index dc3eb6f..7f84f01 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/convert_to_super_parameters.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/convert_to_super_parameters.dart
@@ -139,7 +139,8 @@
       }
 
       // Remove the corresponding arguments.
-      if (argumentsToDelete.length == arguments.length) {
+      if (argumentsToDelete.length == arguments.length &&
+          superInvocation.constructorName == null) {
         var initializers = constructor.initializers;
         SourceRange initializerRange;
         if (initializers.length == 1) {
diff --git a/pkg/analysis_server/test/src/services/correction/assist/convert_to_super_parameters_test.dart b/pkg/analysis_server/test/src/services/correction/assist/convert_to_super_parameters_test.dart
index b3652ca..fc7046b 100644
--- a/pkg/analysis_server/test/src/services/correction/assist/convert_to_super_parameters_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/assist/convert_to_super_parameters_test.dart
@@ -454,6 +454,25 @@
 ''');
   }
 
+  Future<void> test_namedConstructor() async {
+    await resolveTestCode('''
+class A {
+  A.m({int? x});
+}
+class B extends A {
+  B.m({int? x}) : super.m(x: x);
+}
+''');
+    await assertHasAssistAt('B.m', '''
+class A {
+  A.m({int? x});
+}
+class B extends A {
+  B.m({super.x}) : super.m();
+}
+''');
+  }
+
   Future<void> test_positional_first() async {
     await resolveTestCode('''
 class A {