Skip to content

Commit b7f929e

Browse files
asashourCommit Queue
authored andcommitted
[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>
1 parent 6f09cf9 commit b7f929e

File tree

7 files changed

+39
-7
lines changed

7 files changed

+39
-7
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,8 @@ CompileTimeErrorCode.MIXIN_APPLICATION_CONCRETE_SUPER_INVOKED_MEMBER_TYPE:
742742
status: needsEvaluation
743743
CompileTimeErrorCode.MIXIN_APPLICATION_NO_CONCRETE_SUPER_INVOKED_MEMBER:
744744
status: needsEvaluation
745+
CompileTimeErrorCode.MIXIN_APPLICATION_NO_CONCRETE_SUPER_INVOKED_SETTER:
746+
status: needsEvaluation
745747
CompileTimeErrorCode.MIXIN_APPLICATION_NOT_IMPLEMENTED_INTERFACE:
746748
status: hasFix
747749
CompileTimeErrorCode.MIXIN_CLASS_DECLARES_CONSTRUCTOR:

pkg/analyzer/lib/src/error/codes.g.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2923,6 +2923,17 @@ class CompileTimeErrorCode extends AnalyzerErrorCode {
29232923
hasPublishedDocs: true,
29242924
);
29252925

2926+
/// Parameters:
2927+
/// 0: the display name of the setter without a concrete implementation
2928+
static const CompileTimeErrorCode
2929+
MIXIN_APPLICATION_NO_CONCRETE_SUPER_INVOKED_SETTER = CompileTimeErrorCode(
2930+
'MIXIN_APPLICATION_NO_CONCRETE_SUPER_INVOKED_MEMBER',
2931+
"The class doesn't have a concrete implementation of the super-invoked "
2932+
"setter '{0}'.",
2933+
hasPublishedDocs: true,
2934+
uniqueName: 'MIXIN_APPLICATION_NO_CONCRETE_SUPER_INVOKED_SETTER',
2935+
);
2936+
29262937
/// Parameters:
29272938
/// 0: the name of the mixin that is invalid
29282939
static const CompileTimeErrorCode MIXIN_CLASS_DECLARES_CONSTRUCTOR =

pkg/analyzer/lib/src/error/error_code_values.g.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ const List<ErrorCode> errorCodeValues = [
306306
CompileTimeErrorCode.MIXIN_APPLICATION_CONCRETE_SUPER_INVOKED_MEMBER_TYPE,
307307
CompileTimeErrorCode.MIXIN_APPLICATION_NOT_IMPLEMENTED_INTERFACE,
308308
CompileTimeErrorCode.MIXIN_APPLICATION_NO_CONCRETE_SUPER_INVOKED_MEMBER,
309+
CompileTimeErrorCode.MIXIN_APPLICATION_NO_CONCRETE_SUPER_INVOKED_SETTER,
309310
CompileTimeErrorCode.MIXIN_CLASS_DECLARES_CONSTRUCTOR,
310311
CompileTimeErrorCode.MIXIN_DEFERRED_CLASS,
311312
CompileTimeErrorCode.MIXIN_INHERITS_FROM_NOT_OBJECT,

pkg/analyzer/lib/src/generated/error_verifier.dart

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3545,11 +3545,19 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
35453545
forMixinIndex: mixinIndex, concrete: true, forSuper: true);
35463546

35473547
if (superMember == null) {
3548-
errorReporter.reportErrorForNode(
3549-
CompileTimeErrorCode
3550-
.MIXIN_APPLICATION_NO_CONCRETE_SUPER_INVOKED_MEMBER,
3551-
mixinName.name,
3552-
[name]);
3548+
var isSetter = name.endsWith('=');
3549+
3550+
var errorCode = isSetter
3551+
? CompileTimeErrorCode
3552+
.MIXIN_APPLICATION_NO_CONCRETE_SUPER_INVOKED_SETTER
3553+
: CompileTimeErrorCode
3554+
.MIXIN_APPLICATION_NO_CONCRETE_SUPER_INVOKED_MEMBER;
3555+
3556+
if (isSetter) {
3557+
name = name.substring(0, name.length - 1);
3558+
}
3559+
3560+
errorReporter.reportErrorForNode(errorCode, mixinName.name, [name]);
35533561
return true;
35543562
}
35553563

pkg/analyzer/messages.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8687,6 +8687,13 @@ CompileTimeErrorCode:
86878687

86888688
class X = A with M;
86898689
```
8690+
MIXIN_APPLICATION_NO_CONCRETE_SUPER_INVOKED_SETTER:
8691+
sharedName: MIXIN_APPLICATION_NO_CONCRETE_SUPER_INVOKED_MEMBER
8692+
problemMessage: "The class doesn't have a concrete implementation of the super-invoked setter '{0}'."
8693+
hasPublishedDocs: true
8694+
comment: |-
8695+
Parameters:
8696+
0: the display name of the setter without a concrete implementation
86908697
MIXIN_APPLICATION_NO_CONCRETE_SUPER_INVOKED_MEMBER:
86918698
problemMessage: "The class doesn't have a concrete implementation of the super-invoked member '{0}'."
86928699
hasPublishedDocs: true

pkg/analyzer/test/src/diagnostics/mixin_application_no_concrete_super_invoked_member_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ abstract class X extends A with M {}
242242
''', [
243243
error(
244244
CompileTimeErrorCode
245-
.MIXIN_APPLICATION_NO_CONCRETE_SUPER_INVOKED_MEMBER,
245+
.MIXIN_APPLICATION_NO_CONCRETE_SUPER_INVOKED_SETTER,
246246
129,
247247
1),
248248
]);
@@ -385,7 +385,7 @@ enum E with M1, M2 {
385385
''', [
386386
error(
387387
CompileTimeErrorCode
388-
.MIXIN_APPLICATION_NO_CONCRETE_SUPER_INVOKED_MEMBER,
388+
.MIXIN_APPLICATION_NO_CONCRETE_SUPER_INVOKED_SETTER,
389389
106,
390390
2),
391391
]);

pkg/analyzer/tool/diagnostics/diagnostics.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11457,6 +11457,9 @@ class X = A with M;
1145711457
_The class doesn't have a concrete implementation of the super-invoked member
1145811458
'{0}'._
1145911459

11460+
_The class doesn't have a concrete implementation of the super-invoked setter
11461+
'{0}'._
11462+
1146011463
#### Description
1146111464

1146211465
The analyzer produces this diagnostic when a [mixin application][] contains

0 commit comments

Comments
 (0)