@@ -15,10 +15,11 @@ import 'package:analyzer/dart/element/type.dart';
1515import 'package:analyzer/dart/element/type_provider.dart' ;
1616import 'package:analyzer/error/error.dart' ;
1717import 'package:analyzer/error/listener.dart' ;
18+ import 'package:analyzer/src/dart/analysis/session.dart' ;
1819import 'package:analyzer/src/dart/ast/ast.dart' ;
20+ import 'package:analyzer/src/dart/element/class_hierarchy.dart' ;
1921import 'package:analyzer/src/dart/element/element.dart' ;
2022import 'package:analyzer/src/dart/element/inheritance_manager3.dart' ;
21- import 'package:analyzer/src/dart/element/nullability_eliminator.dart' ;
2223import 'package:analyzer/src/dart/element/type.dart' ;
2324import 'package:analyzer/src/dart/resolver/variance.dart' ;
2425import 'package:analyzer/src/diagnostic/diagnostic_factory.dart' ;
@@ -1957,58 +1958,26 @@ class ErrorVerifier extends RecursiveAstVisitor<void> {
19571958 }
19581959
19591960 void _checkForConflictingGenerics (NamedCompilationUnitMember node) {
1960- var visitedClasses = < ClassElement > [];
1961- var interfaces = < ClassElement , InterfaceType > {};
1962-
1963- void visit (InterfaceType type) {
1964- if (type == null ) return ;
1965-
1966- var element = type.element;
1967- if (visitedClasses.contains (element)) return ;
1968- visitedClasses.add (element);
1969-
1970- if (element.typeParameters.isNotEmpty) {
1971- if (_typeSystem.isNonNullableByDefault) {
1972- type = _typeSystem.normalize (type);
1973- var oldType = interfaces[element];
1974- if (oldType == null ) {
1975- interfaces[element] = type;
1976- } else {
1977- try {
1978- var result = _typeSystem.topMerge (oldType, type);
1979- interfaces[element] = result;
1980- } catch (_) {
1981- _errorReporter.reportErrorForNode (
1982- CompileTimeErrorCode .CONFLICTING_GENERIC_INTERFACES ,
1983- node,
1984- [_enclosingClass.name, oldType, type],
1985- );
1986- }
1987- }
1988- } else {
1989- type = _toLegacyType (type);
1990- var oldType = interfaces[element];
1991- if (oldType == null ) {
1992- interfaces[element] = type;
1993- } else if (type != oldType) {
1994- _errorReporter.reportErrorForNode (
1995- CompileTimeErrorCode .CONFLICTING_GENERIC_INTERFACES ,
1996- node,
1997- [_enclosingClass.name, oldType, type],
1998- );
1999- }
2000- }
2001- }
1961+ var element = node.declaredElement as ClassElement ;
20021962
2003- visit (type.superclass);
2004- type.mixins.forEach (visit);
2005- type.superclassConstraints.forEach (visit);
2006- type.interfaces.forEach (visit);
1963+ var analysisSession = _currentLibrary.session as AnalysisSessionImpl ;
1964+ var errors = analysisSession.classHierarchy.errors (element);
20071965
2008- visitedClasses.removeLast ();
1966+ for (var error in errors) {
1967+ if (error is IncompatibleInterfacesClassHierarchyError ) {
1968+ _errorReporter.reportErrorForNode (
1969+ CompileTimeErrorCode .CONFLICTING_GENERIC_INTERFACES ,
1970+ node,
1971+ [
1972+ _enclosingClass.name,
1973+ error.first.getDisplayString (withNullability: true ),
1974+ error.second.getDisplayString (withNullability: true ),
1975+ ],
1976+ );
1977+ } else {
1978+ throw UnimplementedError ('${error .runtimeType }' );
1979+ }
20091980 }
2010-
2011- visit (_enclosingClass.thisType);
20121981 }
20131982
20141983 /**
@@ -5552,13 +5521,6 @@ class ErrorVerifier extends RecursiveAstVisitor<void> {
55525521 return null ;
55535522 }
55545523
5555- /// If in a legacy library, return the legacy version of the [type] .
5556- /// Otherwise, return the original type.
5557- DartType _toLegacyType (DartType type) {
5558- if (_isNonNullableByDefault) return type;
5559- return NullabilityEliminator .perform (_typeProvider, type);
5560- }
5561-
55625524 /**
55635525 * Return [FieldElement] s that are declared in the [ClassDeclaration] with
55645526 * the given [constructor] , but are not initialized.
0 commit comments