commit | aec5b376d8ad88b13a0b757bf3fc839baddc742b | [log] [tgz] |
---|---|---|
author | Brian Wilkerson <brianwilkerson@google.com> | Tue Mar 15 00:35:18 2022 +0000 |
committer | Commit Bot <commit-bot@chromium.org> | Tue Mar 15 00:35:18 2022 +0000 |
tree | 3ec6395bd2a07d81501718cec129dd9544d7d6e5 | |
parent | 935faa6c8a860125a4762296ebca5ff7b4174281 [diff] |
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 {