@@ -6,23 +6,27 @@ import 'package:_fe_analyzer_shared/src/flow_analysis/flow_analysis.dart';
66import 'package:_fe_analyzer_shared/src/types/shared_type.dart' ;
77import 'package:analyzer/dart/ast/ast.dart' ;
88import 'package:analyzer/dart/ast/syntactic_entity.dart' ;
9- import 'package:analyzer/dart/element/element .dart' ;
9+ import 'package:analyzer/dart/element/element2 .dart' ;
1010import 'package:analyzer/dart/element/nullability_suffix.dart' ;
1111import 'package:analyzer/dart/element/type.dart' ;
1212import 'package:analyzer/diagnostic/diagnostic.dart' ;
1313import 'package:analyzer/error/error.dart' ;
1414import 'package:analyzer/error/listener.dart' ;
1515import 'package:analyzer/src/dart/ast/extensions.dart' ;
16+ import 'package:analyzer/src/dart/element/inheritance_manager3.dart' ;
1617import 'package:analyzer/src/dart/element/type.dart' ;
1718import 'package:analyzer/src/dart/element/type_system.dart' ;
1819import 'package:analyzer/src/error/codes.dart' ;
20+ import 'package:analyzer/src/utilities/extensions/object.dart' ;
1921
2022/// Methods useful in detecting errors. This mixin exists to allow code to be
2123/// more easily shared between the two visitors that do the majority of error
2224/// reporting (ResolverVisitor and ErrorVerifier).
2325mixin ErrorDetectionHelpers {
2426 ErrorReporter get errorReporter;
2527
28+ InheritanceManager3 get inheritance;
29+
2630 bool get strictCasts;
2731
2832 TypeSystemImpl get typeSystem;
@@ -61,7 +65,7 @@ mixin ErrorDetectionHelpers {
6165 whyNotPromoted}) {
6266 _checkForArgumentTypeNotAssignableForArgument (
6367 argument: argument is NamedExpression ? argument.expression : argument,
64- parameter: argument.staticParameterElement ,
68+ parameter: argument.correspondingParameter ,
6569 promoteParameterToNullable: promoteParameterToNullable,
6670 whyNotPromoted: whyNotPromoted,
6771 );
@@ -166,7 +170,7 @@ mixin ErrorDetectionHelpers {
166170 /// See [CompileTimeErrorCode.CONST_FIELD_INITIALIZER_NOT_ASSIGNABLE] , and
167171 /// [CompileTimeErrorCode.FIELD_INITIALIZER_NOT_ASSIGNABLE] .
168172 void checkForFieldInitializerNotAssignable (
169- ConstructorFieldInitializer initializer, FieldElement fieldElement,
173+ ConstructorFieldInitializer initializer, FieldElement2 fieldElement,
170174 {required bool isConstConstructor,
171175 required Map <SharedTypeView <DartType >, NonPromotionReason > Function ()?
172176 whyNotPromoted}) {
@@ -256,13 +260,13 @@ mixin ErrorDetectionHelpers {
256260
257261 void checkIndexExpressionIndex (
258262 Expression index, {
259- required ExecutableElement ? readElement,
260- required ExecutableElement ? writeElement,
263+ required ExecutableElement2 ? readElement,
264+ required ExecutableElement2 ? writeElement,
261265 required Map <SharedTypeView <DartType >, NonPromotionReason > Function ()?
262266 whyNotPromoted,
263267 }) {
264- if (readElement is MethodElement ) {
265- var parameters = readElement.parameters ;
268+ if (readElement is MethodElement2 ) {
269+ var parameters = readElement.formalParameters ;
266270 if (parameters.isNotEmpty) {
267271 _checkForArgumentTypeNotAssignableForArgument (
268272 argument: index,
@@ -273,8 +277,8 @@ mixin ErrorDetectionHelpers {
273277 }
274278 }
275279
276- if (writeElement is MethodElement ) {
277- var parameters = writeElement.parameters ;
280+ if (writeElement is MethodElement2 ) {
281+ var parameters = writeElement.formalParameters ;
278282 if (parameters.isNotEmpty) {
279283 _checkForArgumentTypeNotAssignableForArgument (
280284 argument: index,
@@ -309,7 +313,7 @@ mixin ErrorDetectionHelpers {
309313 /// > Let `e` be an expression whose static type is an interface type that has
310314 /// > a method named `call` . In the case where the context type for `e`
311315 /// > is a function type or the type `Function` , `e` is treated as `e.call` .
312- MethodElement ? getImplicitCallMethod (
316+ MethodElement2 ? getImplicitCallMethod (
313317 DartType type, DartType context, SyntacticEntity errorNode) {
314318 var visitedTypes = {type};
315319 while (type is TypeParameterType ) {
@@ -326,19 +330,26 @@ mixin ErrorDetectionHelpers {
326330 if (typeSystem.acceptsFunctionType (context) &&
327331 type is InterfaceType &&
328332 type.nullabilitySuffix != NullabilitySuffix .question) {
329- return type.lookUpMethod2 (
330- FunctionElement .CALL_METHOD_NAME , type.element.library);
333+ return inheritance
334+ .getMember3 (
335+ type,
336+ Name .forLibrary (
337+ type.element3.library2,
338+ MethodElement2 .CALL_METHOD_NAME ,
339+ ),
340+ )
341+ .ifTypeOrNull ();
331342 } else {
332343 return null ;
333344 }
334345 }
335346
336347 /// Return the variable element represented by the given [expression] , or
337348 /// `null` if there is no such element.
338- VariableElement ? getVariableElement (Expression ? expression) {
349+ VariableElement2 ? getVariableElement (Expression ? expression) {
339350 if (expression is Identifier ) {
340- var element = expression.staticElement ;
341- if (element is VariableElement ) {
351+ var element = expression.element ;
352+ if (element is VariableElement2 ) {
342353 return element;
343354 }
344355 }
@@ -347,7 +358,7 @@ mixin ErrorDetectionHelpers {
347358
348359 void _checkForArgumentTypeNotAssignableForArgument ({
349360 required Expression argument,
350- required ParameterElement ? parameter,
361+ required FormalParameterElement ? parameter,
351362 required bool promoteParameterToNullable,
352363 Map <SharedTypeView <DartType >, NonPromotionReason > Function ()?
353364 whyNotPromoted,
0 commit comments