Skip to content

Commit 2e9bd8a

Browse files
pqCommit Queue
authored and
Commit Queue
committed
quick fixes for EXTENSION_{TYPE_}DECLARES_MEMBER_OF_OBJECT
Quick fixes for: * `EXTENSION_DECLARES_MEMBER_OF_OBJECT` * `EXTENSION_TYPE_DECLARES_MEMBER_OF_OBJECT See: #55917 Change-Id: I4a3576f7e78c58a4cf7dd6d659b576f2c7f11279 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/371686 Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Phil Quitslund <[email protected]>
1 parent 25a9fc0 commit 2e9bd8a

File tree

3 files changed

+42
-9
lines changed

3 files changed

+42
-9
lines changed

pkg/analysis_server/lib/src/services/correction/error_fix_status.yaml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@
4545
#
4646
# Stats:
4747
# - 42 "needsEvaluation"
48-
# - 318 "needsFix"
49-
# - 429 "hasFix"
48+
# - 316 "needsFix"
49+
# - 431 "hasFix"
5050
# - 517 "noFix"
5151

5252
AnalysisOptionsErrorCode.INCLUDED_FILE_PARSE_ERROR:
@@ -645,9 +645,7 @@ CompileTimeErrorCode.EXTENSION_AS_EXPRESSION:
645645
CompileTimeErrorCode.EXTENSION_CONFLICTING_STATIC_AND_INSTANCE:
646646
status: noFix
647647
CompileTimeErrorCode.EXTENSION_DECLARES_MEMBER_OF_OBJECT:
648-
status: needsFix
649-
notes: |-
650-
Offer to delete the invalid member.
648+
status: hasFix
651649
CompileTimeErrorCode.EXTENSION_OVERRIDE_ACCESS_TO_STATIC_MEMBER:
652650
status: hasFix
653651
CompileTimeErrorCode.EXTENSION_OVERRIDE_ARGUMENT_NOT_ASSIGNABLE:
@@ -667,9 +665,7 @@ CompileTimeErrorCode.EXTENSION_TYPE_CONSTRUCTOR_WITH_SUPER_INVOCATION:
667665
CompileTimeErrorCode.EXTENSION_TYPE_DECLARES_INSTANCE_FIELD:
668666
status: noFix
669667
CompileTimeErrorCode.EXTENSION_TYPE_DECLARES_MEMBER_OF_OBJECT:
670-
status: needsFix
671-
notes: |-
672-
Offer to delete the invalid member.
668+
status: hasFix
673669
CompileTimeErrorCode.EXTENSION_TYPE_IMPLEMENTS_DISALLOWED_TYPE:
674670
status: noFix
675671
CompileTimeErrorCode.EXTENSION_TYPE_IMPLEMENTS_ITSELF:

pkg/analysis_server/lib/src/services/correction/fix_internal.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -944,6 +944,12 @@ final _builtInNonLintProducers = <ErrorCode, List<ProducerGenerator>>{
944944
CompileTimeErrorCode.EXTENDS_TYPE_ALIAS_EXPANDS_TO_TYPE_PARAMETER: [
945945
RemoveNameFromDeclarationClause.new,
946946
],
947+
CompileTimeErrorCode.EXTENSION_DECLARES_MEMBER_OF_OBJECT: [
948+
RemoveMethodDeclaration.new,
949+
],
950+
CompileTimeErrorCode.EXTENSION_TYPE_DECLARES_MEMBER_OF_OBJECT: [
951+
RemoveMethodDeclaration.new,
952+
],
947953
CompileTimeErrorCode.EXTENSION_OVERRIDE_ACCESS_TO_STATIC_MEMBER: [
948954
ReplaceWithExtensionName.new,
949955
],

pkg/analysis_server/test/src/services/correction/fix/remove_method_declaration_test.dart

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ void main() {
1313
defineReflectiveSuite(() {
1414
defineReflectiveTests(RemoveMethodDeclarationBulkTest);
1515
defineReflectiveTests(RemoveMethodDeclarationTest);
16+
defineReflectiveTests(UnnecessaryOverridesTest);
1617
});
1718
}
1819

@@ -48,7 +49,37 @@ class B extends A {
4849
}
4950

5051
@reflectiveTest
51-
class RemoveMethodDeclarationTest extends FixProcessorLintTest {
52+
class RemoveMethodDeclarationTest extends FixProcessorTest {
53+
@override
54+
FixKind get kind => DartFixKind.REMOVE_METHOD_DECLARATION;
55+
56+
Future<void> test_extensionDeclaresMemberOfObject() async {
57+
await resolveTestCode('''
58+
extension E on String {
59+
bool operator==(Object _) => false;
60+
}
61+
''');
62+
await assertHasFix('''
63+
extension E on String {
64+
}
65+
''');
66+
}
67+
68+
Future<void> test_extensionTypeDeclaresMemberOfObject() async {
69+
await resolveTestCode('''
70+
extension type E(int i) {
71+
int get hashCode => 0;
72+
}
73+
''');
74+
await assertHasFix('''
75+
extension type E(int i) {
76+
}
77+
''');
78+
}
79+
}
80+
81+
@reflectiveTest
82+
class UnnecessaryOverridesTest extends FixProcessorLintTest {
5283
@override
5384
FixKind get kind => DartFixKind.REMOVE_METHOD_DECLARATION;
5485

0 commit comments

Comments
 (0)