diff --git a/pkg/analyzer/lib/src/error/codes.g.dart b/pkg/analyzer/lib/src/error/codes.g.dart index fdd367635c4..6a03b7d2c21 100644 --- a/pkg/analyzer/lib/src/error/codes.g.dart +++ b/pkg/analyzer/lib/src/error/codes.g.dart @@ -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, ); diff --git a/pkg/analyzer/lib/src/generated/error_verifier.dart b/pkg/analyzer/lib/src/generated/error_verifier.dart index 4b0bc8a9127..ad2b2c8ef5a 100644 --- a/pkg/analyzer/lib/src/generated/error_verifier.dart +++ b/pkg/analyzer/lib/src/generated/error_verifier.dart @@ -707,6 +707,7 @@ class ErrorVerifier extends RecursiveAstVisitor _duplicateDefinitionVerifier.checkExtensionType(node, declarationElement); _checkForConflictingClassMembers(); + _checkForConflictingGenerics(node); _constructorFieldsVerifier.enterExtensionType(node, declarationElement); _checkForNonCovariantTypeParameterPositionInRepresentationType( node, element); @@ -2175,6 +2176,7 @@ class ErrorVerifier extends RecursiveAstVisitor CompileTimeErrorCode.CONFLICTING_GENERIC_INTERFACES, node.name, [ + _enclosingClass!.kind.displayName, _enclosingClass!.name, error.first.getDisplayString(withNullability: true), error.second.getDisplayString(withNullability: true), diff --git a/pkg/analyzer/messages.yaml b/pkg/analyzer/messages.yaml index 307880c44d1..15b0b2eb004 100644 --- a/pkg/analyzer/messages.yaml +++ b/pkg/analyzer/messages.yaml @@ -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 diff --git a/pkg/analyzer/test/src/diagnostics/conflicting_generic_interfaces_test.dart b/pkg/analyzer/test/src/diagnostics/conflicting_generic_interfaces_test.dart index 7eac918358c..8b051200fbd 100644 --- a/pkg/analyzer/test/src/diagnostics/conflicting_generic_interfaces_test.dart +++ b/pkg/analyzer/test/src/diagnostics/conflicting_generic_interfaces_test.dart @@ -205,6 +205,17 @@ enum E with M1, M2 { ]); } + test_extensionType() async { + await assertErrorsInCode(''' +class I {} +class A implements I {} +class B implements I {} +extension type C(Never it) implements A, B {} +''', [ + error(CompileTimeErrorCode.CONFLICTING_GENERIC_INTERFACES, 87, 1), + ]); + } + test_mixin_on_implements() async { await assertErrorsInCode(''' class I {}