Skip to content

Commit 94a0ce7

Browse files
committed
Extension types. Report CONFLICTING_GENERIC_INTERFACES.
Change-Id: Idd4a844ba5ee993b70c08aa9227e2f3a95fcc2f2 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/319782 Commit-Queue: Konstantin Shcheglov <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]> Reviewed-by: Phil Quitslund <[email protected]>
1 parent 9860866 commit 94a0ce7

File tree

4 files changed

+23
-8
lines changed

4 files changed

+23
-8
lines changed

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -521,13 +521,14 @@ class CompileTimeErrorCode extends AnalyzerErrorCode {
521521
);
522522

523523
/// Parameters:
524-
/// 0: the name of the class implementing the conflicting interface
525-
/// 1: the first conflicting type
526-
/// 2: the second conflicting type
524+
/// 0: the name of the kind of the element implementing the conflicting interface
525+
/// 1: the name of the element implementing the conflicting interface
526+
/// 2: the first conflicting type
527+
/// 3: the second conflicting type
527528
static const CompileTimeErrorCode CONFLICTING_GENERIC_INTERFACES =
528529
CompileTimeErrorCode(
529530
'CONFLICTING_GENERIC_INTERFACES',
530-
"The class '{0}' can't implement both '{1}' and '{2}' because the type "
531+
"The {0} '{1}' can't implement both '{2}' and '{3}' because the type "
531532
"arguments are different.",
532533
hasPublishedDocs: true,
533534
);

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -707,6 +707,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
707707

708708
_duplicateDefinitionVerifier.checkExtensionType(node, declarationElement);
709709
_checkForConflictingClassMembers();
710+
_checkForConflictingGenerics(node);
710711
_constructorFieldsVerifier.enterExtensionType(node, declarationElement);
711712
_checkForNonCovariantTypeParameterPositionInRepresentationType(
712713
node, element);
@@ -2175,6 +2176,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
21752176
CompileTimeErrorCode.CONFLICTING_GENERIC_INTERFACES,
21762177
node.name,
21772178
[
2179+
_enclosingClass!.kind.displayName,
21782180
_enclosingClass!.name,
21792181
error.first.getDisplayString(withNullability: true),
21802182
error.second.getDisplayString(withNullability: true),

pkg/analyzer/messages.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2079,13 +2079,14 @@ CompileTimeErrorCode:
20792079
1: the name of the conflicting field
20802080
2: the name of the class defining the method with which the field conflicts
20812081
CONFLICTING_GENERIC_INTERFACES:
2082-
problemMessage: "The class '{0}' can't implement both '{1}' and '{2}' because the type arguments are different."
2082+
problemMessage: "The {0} '{1}' can't implement both '{2}' and '{3}' because the type arguments are different."
20832083
hasPublishedDocs: true
20842084
comment: |-
20852085
Parameters:
2086-
0: the name of the class implementing the conflicting interface
2087-
1: the first conflicting type
2088-
2: the second conflicting type
2086+
0: the name of the kind of the element implementing the conflicting interface
2087+
1: the name of the element implementing the conflicting interface
2088+
2: the first conflicting type
2089+
3: the second conflicting type
20892090
documentation: |-
20902091
#### Description
20912092

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,17 @@ enum E with M1, M2 {
205205
]);
206206
}
207207

208+
test_extensionType() async {
209+
await assertErrorsInCode('''
210+
class I<T> {}
211+
class A implements I<int> {}
212+
class B implements I<num> {}
213+
extension type C(Never it) implements A, B {}
214+
''', [
215+
error(CompileTimeErrorCode.CONFLICTING_GENERIC_INTERFACES, 87, 1),
216+
]);
217+
}
218+
208219
test_mixin_on_implements() async {
209220
await assertErrorsInCode('''
210221
class I<T> {}

0 commit comments

Comments
 (0)