[analyzer] improve error message of
`MIXIN_APPLICATION_NO_CONCRETE_SUPER_INVOKED_MEMBER` for setters
Bug: #49355
Change-Id: Ic2ae5cbb8f9e795cee672accacfbaeb5ea1b16fc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279717
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@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 e8e1748..9b98e99 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
@@ -742,6 +742,8 @@
status: needsEvaluation
CompileTimeErrorCode.MIXIN_APPLICATION_NO_CONCRETE_SUPER_INVOKED_MEMBER:
status: needsEvaluation
+CompileTimeErrorCode.MIXIN_APPLICATION_NO_CONCRETE_SUPER_INVOKED_SETTER:
+ status: needsEvaluation
CompileTimeErrorCode.MIXIN_APPLICATION_NOT_IMPLEMENTED_INTERFACE:
status: hasFix
CompileTimeErrorCode.MIXIN_CLASS_DECLARES_CONSTRUCTOR:
diff --git a/pkg/analyzer/lib/src/error/codes.g.dart b/pkg/analyzer/lib/src/error/codes.g.dart
index d1c0167..0ae66d6 100644
--- a/pkg/analyzer/lib/src/error/codes.g.dart
+++ b/pkg/analyzer/lib/src/error/codes.g.dart
@@ -2924,6 +2924,17 @@
);
/// Parameters:
+ /// 0: the display name of the setter without a concrete implementation
+ static const CompileTimeErrorCode
+ MIXIN_APPLICATION_NO_CONCRETE_SUPER_INVOKED_SETTER = CompileTimeErrorCode(
+ 'MIXIN_APPLICATION_NO_CONCRETE_SUPER_INVOKED_MEMBER',
+ "The class doesn't have a concrete implementation of the super-invoked "
+ "setter '{0}'.",
+ hasPublishedDocs: true,
+ uniqueName: 'MIXIN_APPLICATION_NO_CONCRETE_SUPER_INVOKED_SETTER',
+ );
+
+ /// Parameters:
/// 0: the name of the mixin that is invalid
static const CompileTimeErrorCode MIXIN_CLASS_DECLARES_CONSTRUCTOR =
CompileTimeErrorCode(
diff --git a/pkg/analyzer/lib/src/error/error_code_values.g.dart b/pkg/analyzer/lib/src/error/error_code_values.g.dart
index 2a67b49..ee8850f 100644
--- a/pkg/analyzer/lib/src/error/error_code_values.g.dart
+++ b/pkg/analyzer/lib/src/error/error_code_values.g.dart
@@ -306,6 +306,7 @@
CompileTimeErrorCode.MIXIN_APPLICATION_CONCRETE_SUPER_INVOKED_MEMBER_TYPE,
CompileTimeErrorCode.MIXIN_APPLICATION_NOT_IMPLEMENTED_INTERFACE,
CompileTimeErrorCode.MIXIN_APPLICATION_NO_CONCRETE_SUPER_INVOKED_MEMBER,
+ CompileTimeErrorCode.MIXIN_APPLICATION_NO_CONCRETE_SUPER_INVOKED_SETTER,
CompileTimeErrorCode.MIXIN_CLASS_DECLARES_CONSTRUCTOR,
CompileTimeErrorCode.MIXIN_DEFERRED_CLASS,
CompileTimeErrorCode.MIXIN_INHERITS_FROM_NOT_OBJECT,
diff --git a/pkg/analyzer/lib/src/generated/error_verifier.dart b/pkg/analyzer/lib/src/generated/error_verifier.dart
index 4dd262a..e0d5ff2 100644
--- a/pkg/analyzer/lib/src/generated/error_verifier.dart
+++ b/pkg/analyzer/lib/src/generated/error_verifier.dart
@@ -3545,11 +3545,19 @@
forMixinIndex: mixinIndex, concrete: true, forSuper: true);
if (superMember == null) {
- errorReporter.reportErrorForNode(
- CompileTimeErrorCode
- .MIXIN_APPLICATION_NO_CONCRETE_SUPER_INVOKED_MEMBER,
- mixinName.name,
- [name]);
+ var isSetter = name.endsWith('=');
+
+ var errorCode = isSetter
+ ? CompileTimeErrorCode
+ .MIXIN_APPLICATION_NO_CONCRETE_SUPER_INVOKED_SETTER
+ : CompileTimeErrorCode
+ .MIXIN_APPLICATION_NO_CONCRETE_SUPER_INVOKED_MEMBER;
+
+ if (isSetter) {
+ name = name.substring(0, name.length - 1);
+ }
+
+ errorReporter.reportErrorForNode(errorCode, mixinName.name, [name]);
return true;
}
diff --git a/pkg/analyzer/messages.yaml b/pkg/analyzer/messages.yaml
index 56df52a..b028b00 100644
--- a/pkg/analyzer/messages.yaml
+++ b/pkg/analyzer/messages.yaml
@@ -8687,6 +8687,13 @@
class X = A with M;
```
+ MIXIN_APPLICATION_NO_CONCRETE_SUPER_INVOKED_SETTER:
+ sharedName: MIXIN_APPLICATION_NO_CONCRETE_SUPER_INVOKED_MEMBER
+ problemMessage: "The class doesn't have a concrete implementation of the super-invoked setter '{0}'."
+ hasPublishedDocs: true
+ comment: |-
+ Parameters:
+ 0: the display name of the setter without a concrete implementation
MIXIN_APPLICATION_NO_CONCRETE_SUPER_INVOKED_MEMBER:
problemMessage: "The class doesn't have a concrete implementation of the super-invoked member '{0}'."
hasPublishedDocs: true
diff --git a/pkg/analyzer/test/src/diagnostics/mixin_application_no_concrete_super_invoked_member_test.dart b/pkg/analyzer/test/src/diagnostics/mixin_application_no_concrete_super_invoked_member_test.dart
index 77c785a..d64ee32 100644
--- a/pkg/analyzer/test/src/diagnostics/mixin_application_no_concrete_super_invoked_member_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/mixin_application_no_concrete_super_invoked_member_test.dart
@@ -242,7 +242,7 @@
''', [
error(
CompileTimeErrorCode
- .MIXIN_APPLICATION_NO_CONCRETE_SUPER_INVOKED_MEMBER,
+ .MIXIN_APPLICATION_NO_CONCRETE_SUPER_INVOKED_SETTER,
129,
1),
]);
@@ -385,7 +385,7 @@
''', [
error(
CompileTimeErrorCode
- .MIXIN_APPLICATION_NO_CONCRETE_SUPER_INVOKED_MEMBER,
+ .MIXIN_APPLICATION_NO_CONCRETE_SUPER_INVOKED_SETTER,
106,
2),
]);
diff --git a/pkg/analyzer/tool/diagnostics/diagnostics.md b/pkg/analyzer/tool/diagnostics/diagnostics.md
index 4a7ea1f..512715d 100644
--- a/pkg/analyzer/tool/diagnostics/diagnostics.md
+++ b/pkg/analyzer/tool/diagnostics/diagnostics.md
@@ -11457,6 +11457,9 @@
_The class doesn't have a concrete implementation of the super-invoked member
'{0}'._
+_The class doesn't have a concrete implementation of the super-invoked setter
+'{0}'._
+
#### Description
The analyzer produces this diagnostic when a [mixin application][] contains