Skip to content

Commit 991adea

Browse files
asashourCommit Queue
authored andcommitted
[analyzer] improve error message of
`PRIVATE_COLLISION_IN_MIXIN_APPLICATION` for setters Bug: #49355 Change-Id: Iacd40b5c996040f279c2630a4962eed26e28546a Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279719 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
1 parent b7f929e commit 991adea

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3606,10 +3606,12 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
36063606
bool isConflictingName(
36073607
String name, LibraryElement library, NamedType namedType) {
36083608
if (Identifier.isPrivateName(name)) {
3609-
Map<String, String> names =
3610-
mixedInNames.putIfAbsent(library, () => <String, String>{});
3609+
Map<String, String> names = mixedInNames.putIfAbsent(library, () => {});
36113610
var conflictingName = names[name];
36123611
if (conflictingName != null) {
3612+
if (name.endsWith('=')) {
3613+
name = name.substring(0, name.length - 1);
3614+
}
36133615
errorReporter.reportErrorForNode(
36143616
CompileTimeErrorCode.PRIVATE_COLLISION_IN_MIXIN_APPLICATION,
36153617
namedType,
@@ -3623,6 +3625,9 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
36233625
concrete: true,
36243626
);
36253627
if (inheritedMember != null) {
3628+
if (name.endsWith('=')) {
3629+
name = name.substring(0, name.length - 1);
3630+
}
36263631
// Inherited members are always contained inside named elements, so we
36273632
// can safely assume `inheritedMember.enclosingElement3.name` is
36283633
// non-`null`.

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,8 @@ import 'a.dart';
369369
370370
class C extends A with B {}
371371
''', [
372-
error(CompileTimeErrorCode.PRIVATE_COLLISION_IN_MIXIN_APPLICATION, 41, 1),
372+
error(CompileTimeErrorCode.PRIVATE_COLLISION_IN_MIXIN_APPLICATION, 41, 1,
373+
messageContains: ["'_foo'"]),
373374
]);
374375
}
375376

@@ -389,7 +390,8 @@ import 'a.dart';
389390
390391
class C extends A with B {}
391392
''', [
392-
error(CompileTimeErrorCode.PRIVATE_COLLISION_IN_MIXIN_APPLICATION, 41, 1),
393+
error(CompileTimeErrorCode.PRIVATE_COLLISION_IN_MIXIN_APPLICATION, 41, 1,
394+
messageContains: ["'_foo'"]),
393395
]);
394396
}
395397

@@ -614,7 +616,8 @@ enum E with A, B {
614616
v
615617
}
616618
''', [
617-
error(CompileTimeErrorCode.PRIVATE_COLLISION_IN_MIXIN_APPLICATION, 33, 1),
619+
error(CompileTimeErrorCode.PRIVATE_COLLISION_IN_MIXIN_APPLICATION, 33, 1,
620+
messageContains: ["'_foo'"]),
618621
]);
619622
}
620623
}

0 commit comments

Comments
 (0)