1
0
mirror of https://github.com/dart-lang/sdk synced 2024-07-08 12:06:26 +00:00

Extension types. Report CONFLICTING_GENERIC_INTERFACES.

Change-Id: Idd4a844ba5ee993b70c08aa9227e2f3a95fcc2f2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/319782
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
This commit is contained in:
Konstantin Shcheglov 2023-08-10 17:01:31 +00:00
parent 98608662e7
commit 94a0ce7757
4 changed files with 23 additions and 8 deletions

View File

@ -521,13 +521,14 @@ class CompileTimeErrorCode extends AnalyzerErrorCode {
);
/// Parameters:
/// 0: the name of the class implementing the conflicting interface
/// 1: the first conflicting type
/// 2: the second conflicting type
/// 0: the name of the kind of the element implementing the conflicting interface
/// 1: the name of the element implementing the conflicting interface
/// 2: the first conflicting type
/// 3: the second conflicting type
static const CompileTimeErrorCode CONFLICTING_GENERIC_INTERFACES =
CompileTimeErrorCode(
'CONFLICTING_GENERIC_INTERFACES',
"The class '{0}' can't implement both '{1}' and '{2}' because the type "
"The {0} '{1}' can't implement both '{2}' and '{3}' because the type "
"arguments are different.",
hasPublishedDocs: true,
);

View File

@ -707,6 +707,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
_duplicateDefinitionVerifier.checkExtensionType(node, declarationElement);
_checkForConflictingClassMembers();
_checkForConflictingGenerics(node);
_constructorFieldsVerifier.enterExtensionType(node, declarationElement);
_checkForNonCovariantTypeParameterPositionInRepresentationType(
node, element);
@ -2175,6 +2176,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
CompileTimeErrorCode.CONFLICTING_GENERIC_INTERFACES,
node.name,
[
_enclosingClass!.kind.displayName,
_enclosingClass!.name,
error.first.getDisplayString(withNullability: true),
error.second.getDisplayString(withNullability: true),

View File

@ -2079,13 +2079,14 @@ CompileTimeErrorCode:
1: the name of the conflicting field
2: the name of the class defining the method with which the field conflicts
CONFLICTING_GENERIC_INTERFACES:
problemMessage: "The class '{0}' can't implement both '{1}' and '{2}' because the type arguments are different."
problemMessage: "The {0} '{1}' can't implement both '{2}' and '{3}' because the type arguments are different."
hasPublishedDocs: true
comment: |-
Parameters:
0: the name of the class implementing the conflicting interface
1: the first conflicting type
2: the second conflicting type
0: the name of the kind of the element implementing the conflicting interface
1: the name of the element implementing the conflicting interface
2: the first conflicting type
3: the second conflicting type
documentation: |-
#### Description

View File

@ -205,6 +205,17 @@ enum E with M1, M2 {
]);
}
test_extensionType() async {
await assertErrorsInCode('''
class I<T> {}
class A implements I<int> {}
class B implements I<num> {}
extension type C(Never it) implements A, B {}
''', [
error(CompileTimeErrorCode.CONFLICTING_GENERIC_INTERFACES, 87, 1),
]);
}
test_mixin_on_implements() async {
await assertErrorsInCode('''
class I<T> {}