mirror of
https://github.com/dart-lang/sdk
synced 2024-10-06 13:08:01 +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:
parent
98608662e7
commit
94a0ce7757
|
@ -521,13 +521,14 @@ class CompileTimeErrorCode extends AnalyzerErrorCode {
|
||||||
);
|
);
|
||||||
|
|
||||||
/// Parameters:
|
/// Parameters:
|
||||||
/// 0: the name of the class implementing the conflicting interface
|
/// 0: the name of the kind of the element implementing the conflicting interface
|
||||||
/// 1: the first conflicting type
|
/// 1: the name of the element implementing the conflicting interface
|
||||||
/// 2: the second conflicting type
|
/// 2: the first conflicting type
|
||||||
|
/// 3: the second conflicting type
|
||||||
static const CompileTimeErrorCode CONFLICTING_GENERIC_INTERFACES =
|
static const CompileTimeErrorCode CONFLICTING_GENERIC_INTERFACES =
|
||||||
CompileTimeErrorCode(
|
CompileTimeErrorCode(
|
||||||
'CONFLICTING_GENERIC_INTERFACES',
|
'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.",
|
"arguments are different.",
|
||||||
hasPublishedDocs: true,
|
hasPublishedDocs: true,
|
||||||
);
|
);
|
||||||
|
|
|
@ -707,6 +707,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
|
||||||
|
|
||||||
_duplicateDefinitionVerifier.checkExtensionType(node, declarationElement);
|
_duplicateDefinitionVerifier.checkExtensionType(node, declarationElement);
|
||||||
_checkForConflictingClassMembers();
|
_checkForConflictingClassMembers();
|
||||||
|
_checkForConflictingGenerics(node);
|
||||||
_constructorFieldsVerifier.enterExtensionType(node, declarationElement);
|
_constructorFieldsVerifier.enterExtensionType(node, declarationElement);
|
||||||
_checkForNonCovariantTypeParameterPositionInRepresentationType(
|
_checkForNonCovariantTypeParameterPositionInRepresentationType(
|
||||||
node, element);
|
node, element);
|
||||||
|
@ -2175,6 +2176,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
|
||||||
CompileTimeErrorCode.CONFLICTING_GENERIC_INTERFACES,
|
CompileTimeErrorCode.CONFLICTING_GENERIC_INTERFACES,
|
||||||
node.name,
|
node.name,
|
||||||
[
|
[
|
||||||
|
_enclosingClass!.kind.displayName,
|
||||||
_enclosingClass!.name,
|
_enclosingClass!.name,
|
||||||
error.first.getDisplayString(withNullability: true),
|
error.first.getDisplayString(withNullability: true),
|
||||||
error.second.getDisplayString(withNullability: true),
|
error.second.getDisplayString(withNullability: true),
|
||||||
|
|
|
@ -2079,13 +2079,14 @@ CompileTimeErrorCode:
|
||||||
1: the name of the conflicting field
|
1: the name of the conflicting field
|
||||||
2: the name of the class defining the method with which the field conflicts
|
2: the name of the class defining the method with which the field conflicts
|
||||||
CONFLICTING_GENERIC_INTERFACES:
|
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
|
hasPublishedDocs: true
|
||||||
comment: |-
|
comment: |-
|
||||||
Parameters:
|
Parameters:
|
||||||
0: the name of the class implementing the conflicting interface
|
0: the name of the kind of the element implementing the conflicting interface
|
||||||
1: the first conflicting type
|
1: the name of the element implementing the conflicting interface
|
||||||
2: the second conflicting type
|
2: the first conflicting type
|
||||||
|
3: the second conflicting type
|
||||||
documentation: |-
|
documentation: |-
|
||||||
#### Description
|
#### Description
|
||||||
|
|
||||||
|
|
|
@ -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 {
|
test_mixin_on_implements() async {
|
||||||
await assertErrorsInCode('''
|
await assertErrorsInCode('''
|
||||||
class I<T> {}
|
class I<T> {}
|
||||||
|
|
Loading…
Reference in a new issue