quick fix for `INVALID_MODIFIER_ON_CONSTRUCTOR`
Change-Id: I45d1f7676a310185556ff8945330bdb76d3f11ff
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/367145
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
diff --git a/pkg/analysis_server/lib/src/services/correction/error_fix_status.yaml b/pkg/analysis_server/lib/src/services/correction/error_fix_status.yaml
index ac192dd..048837b 100644
--- a/pkg/analysis_server/lib/src/services/correction/error_fix_status.yaml
+++ b/pkg/analysis_server/lib/src/services/correction/error_fix_status.yaml
@@ -984,9 +984,7 @@
CompileTimeErrorCode.INVALID_MACRO_APPLICATION_TARGET:
status: noFix
CompileTimeErrorCode.INVALID_MODIFIER_ON_CONSTRUCTOR:
- status: needsFix
- notes: |-
- Remove the modifier.
+ status: hasFix
CompileTimeErrorCode.INVALID_MODIFIER_ON_SETTER:
status: needsFix
notes: |-
diff --git a/pkg/analysis_server/lib/src/services/correction/fix_internal.dart b/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
index a7e086a..df151bf 100644
--- a/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
+++ b/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
@@ -1015,6 +1015,9 @@
ChangeTypeAnnotation.new,
MakeVariableNullable.new,
],
+ CompileTimeErrorCode.INVALID_MODIFIER_ON_CONSTRUCTOR: [
+ RemoveExtraModifier.new,
+ ],
CompileTimeErrorCode.INVOCATION_OF_NON_FUNCTION_EXPRESSION: [
RemoveParenthesesInGetterInvocation.new,
],
diff --git a/pkg/analysis_server/test/src/services/correction/fix/remove_extra_modifier_test.dart b/pkg/analysis_server/test/src/services/correction/fix/remove_extra_modifier_test.dart
index ef31668..5d753db 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/remove_extra_modifier_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/remove_extra_modifier_test.dart
@@ -51,6 +51,19 @@
@override
FixKind get kind => DartFixKind.REMOVE_EXTRA_MODIFIER;
+ test_invalidAsyncConstructorModifier() async {
+ await resolveTestCode(r'''
+class A {
+ A() async {}
+}
+''');
+ await assertHasFix('''
+class A {
+ A() {}
+}
+''');
+ }
+
Future<void> test_it() async {
newFile('$testPackageLibPath/a.dart', '''
import augment 'test.dart';