@@ -1248,6 +1248,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void> {
1248
1248
_checkForRepeatedType (implementsClause? .interfaces,
1249
1249
CompileTimeErrorCode .IMPLEMENTS_REPEATED );
1250
1250
_checkImplementsSuperClass (implementsClause);
1251
+ _checkMixinsSuperClass (withClause);
1251
1252
_checkMixinInference (node, withClause);
1252
1253
_checkForMixinWithConflictingPrivateMember (withClause, superclass);
1253
1254
_checkForConflictingGenerics (node);
@@ -4626,27 +4627,27 @@ class ErrorVerifier extends RecursiveAstVisitor<void> {
4626
4627
}
4627
4628
}
4628
4629
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.
4631
4632
///
4632
4633
/// See [CompileTimeErrorCode.IMPLEMENTS_SUPER_CLASS] .
4633
4634
void _checkImplementsSuperClass (ImplementsClause implementsClause) {
4634
- // prepare super type
4635
- InterfaceType superType = _enclosingClass.supertype;
4636
- if (superType == null ) {
4635
+ if (implementsClause == null ) {
4637
4636
return ;
4638
4637
}
4639
- // prepare interfaces
4640
- if (implementsClause == null ) {
4638
+
4639
+ var superElement = _enclosingClass.supertype? .element;
4640
+ if (superElement == null ) {
4641
4641
return ;
4642
4642
}
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 ) {
4646
4646
_errorReporter.reportErrorForNode (
4647
- CompileTimeErrorCode .IMPLEMENTS_SUPER_CLASS ,
4648
- interfaceNode,
4649
- [superType]);
4647
+ CompileTimeErrorCode .IMPLEMENTS_SUPER_CLASS ,
4648
+ interfaceNode,
4649
+ [superElement],
4650
+ );
4650
4651
}
4651
4652
}
4652
4653
}
@@ -4720,6 +4721,31 @@ class ErrorVerifier extends RecursiveAstVisitor<void> {
4720
4721
}
4721
4722
}
4722
4723
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
+
4723
4749
void _checkUseOfCovariantInParameters (FormalParameterList node) {
4724
4750
AstNode parent = node.parent;
4725
4751
if (_enclosingClass != null &&
0 commit comments