@@ -1248,6 +1248,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void> {
12481248 _checkForRepeatedType (implementsClause? .interfaces,
12491249 CompileTimeErrorCode .IMPLEMENTS_REPEATED );
12501250 _checkImplementsSuperClass (implementsClause);
1251+ _checkMixinsSuperClass (withClause);
12511252 _checkMixinInference (node, withClause);
12521253 _checkForMixinWithConflictingPrivateMember (withClause, superclass);
12531254 _checkForConflictingGenerics (node);
@@ -4626,27 +4627,27 @@ class ErrorVerifier extends RecursiveAstVisitor<void> {
46264627 }
46274628 }
46284629
4629- /// Verify that the given class [declaration] does not have the same class in
4630- /// the 'extends' and 'implements' clauses.
4630+ /// Verify that the current class does not have the same class in the
4631+ /// 'extends' and 'implements' clauses.
46314632 ///
46324633 /// See [CompileTimeErrorCode.IMPLEMENTS_SUPER_CLASS] .
46334634 void _checkImplementsSuperClass (ImplementsClause implementsClause) {
4634- // prepare super type
4635- InterfaceType superType = _enclosingClass.supertype;
4636- if (superType == null ) {
4635+ if (implementsClause == null ) {
46374636 return ;
46384637 }
4639- // prepare interfaces
4640- if (implementsClause == null ) {
4638+
4639+ var superElement = _enclosingClass.supertype? .element;
4640+ if (superElement == null ) {
46414641 return ;
46424642 }
4643- // check interfaces
4644- for (TypeName interfaceNode in implementsClause.interfaces) {
4645- if (interfaceNode.type == superType ) {
4643+
4644+ for (var interfaceNode in implementsClause.interfaces) {
4645+ if (interfaceNode.type.element == superElement ) {
46464646 _errorReporter.reportErrorForNode (
4647- CompileTimeErrorCode .IMPLEMENTS_SUPER_CLASS ,
4648- interfaceNode,
4649- [superType]);
4647+ CompileTimeErrorCode .IMPLEMENTS_SUPER_CLASS ,
4648+ interfaceNode,
4649+ [superElement],
4650+ );
46504651 }
46514652 }
46524653 }
@@ -4720,6 +4721,31 @@ class ErrorVerifier extends RecursiveAstVisitor<void> {
47204721 }
47214722 }
47224723
4724+ /// Verify that the current class does not have the same class in the
4725+ /// 'extends' and 'with' clauses.
4726+ ///
4727+ /// See [CompileTimeErrorCode.IMPLEMENTS_SUPER_CLASS] .
4728+ void _checkMixinsSuperClass (WithClause withClause) {
4729+ if (withClause == null ) {
4730+ return ;
4731+ }
4732+
4733+ var superElement = _enclosingClass.supertype? .element;
4734+ if (superElement == null ) {
4735+ return ;
4736+ }
4737+
4738+ for (var mixinNode in withClause.mixinTypes) {
4739+ if (mixinNode.type.element == superElement) {
4740+ _errorReporter.reportErrorForNode (
4741+ CompileTimeErrorCode .MIXINS_SUPER_CLASS ,
4742+ mixinNode,
4743+ [superElement],
4744+ );
4745+ }
4746+ }
4747+ }
4748+
47234749 void _checkUseOfCovariantInParameters (FormalParameterList node) {
47244750 AstNode parent = node.parent;
47254751 if (_enclosingClass != null &&
0 commit comments