diff --git a/pkg/analyzer/lib/src/dart/resolver/annotation_resolver.dart b/pkg/analyzer/lib/src/dart/resolver/annotation_resolver.dart index f43c0562598..e50459e4af3 100644 --- a/pkg/analyzer/lib/src/dart/resolver/annotation_resolver.dart +++ b/pkg/analyzer/lib/src/dart/resolver/annotation_resolver.dart @@ -115,11 +115,10 @@ class AnnotationResolver { resolver: _resolver, node: node, argumentList: argumentList, - rawType: null, contextType: null, whyNotPromotedList: whyNotPromotedList, constructorName: constructorName) - .resolveInvocation(); + .resolveInvocation(rawType: null); return; } @@ -133,11 +132,10 @@ class AnnotationResolver { resolver: _resolver, node: node, argumentList: argumentList, - rawType: constructorRawType, contextType: null, whyNotPromotedList: whyNotPromotedList, constructorName: constructorName) - .resolveInvocation(); + .resolveInvocation(rawType: constructorRawType); } void _extensionGetter( @@ -407,11 +405,10 @@ class AnnotationResolver { resolver: _resolver, node: node, argumentList: arguments, - rawType: null, contextType: null, whyNotPromotedList: whyNotPromotedList, constructorName: null) - .resolveInvocation(); + .resolveInvocation(rawType: null); } } } diff --git a/pkg/analyzer/lib/src/dart/resolver/function_expression_invocation_resolver.dart b/pkg/analyzer/lib/src/dart/resolver/function_expression_invocation_resolver.dart index 03d46015601..26bb2562f99 100644 --- a/pkg/analyzer/lib/src/dart/resolver/function_expression_invocation_resolver.dart +++ b/pkg/analyzer/lib/src/dart/resolver/function_expression_invocation_resolver.dart @@ -119,10 +119,9 @@ class FunctionExpressionInvocationResolver { resolver: _resolver, node: node, argumentList: node.argumentList, - rawType: rawType, whyNotPromotedList: whyNotPromotedList, contextType: contextType, - ).resolveInvocation(); + ).resolveInvocation(rawType: rawType); _inferenceHelper.recordStaticType(node, returnType, contextType: contextType); @@ -209,10 +208,9 @@ class FunctionExpressionInvocationResolver { resolver: _resolver, node: node, argumentList: node.argumentList, - rawType: null, contextType: contextType, whyNotPromotedList: whyNotPromotedList) - .resolveInvocation(); + .resolveInvocation(rawType: null); node.staticInvokeType = DynamicTypeImpl.instance; node.staticType = type; } diff --git a/pkg/analyzer/lib/src/dart/resolver/instance_creation_expression_resolver.dart b/pkg/analyzer/lib/src/dart/resolver/instance_creation_expression_resolver.dart index 7445573d9ac..71472faf2dc 100644 --- a/pkg/analyzer/lib/src/dart/resolver/instance_creation_expression_resolver.dart +++ b/pkg/analyzer/lib/src/dart/resolver/instance_creation_expression_resolver.dart @@ -66,10 +66,9 @@ class InstanceCreationExpressionResolver { resolver: _resolver, node: node, argumentList: node.argumentList, - rawType: elementToInfer?.asType, contextType: contextType, whyNotPromotedList: whyNotPromotedList) - .resolveInvocation(); + .resolveInvocation(rawType: elementToInfer?.asType); _resolver.inferenceHelper.recordStaticType( node, node.constructorName.type.type!, contextType: contextType); diff --git a/pkg/analyzer/lib/src/dart/resolver/invocation_inference_helper.dart b/pkg/analyzer/lib/src/dart/resolver/invocation_inference_helper.dart index 495866ad0c0..ee320b594bd 100644 --- a/pkg/analyzer/lib/src/dart/resolver/invocation_inference_helper.dart +++ b/pkg/analyzer/lib/src/dart/resolver/invocation_inference_helper.dart @@ -174,10 +174,9 @@ class InvocationInferenceHelper { resolver: _resolver, node: node, argumentList: node.argumentList, - rawType: rawType, contextType: contextType, whyNotPromotedList: whyNotPromotedList, - ).resolveInvocation(); + ).resolveInvocation(rawType: rawType); recordStaticType(node, returnType, contextType: contextType); } diff --git a/pkg/analyzer/lib/src/dart/resolver/invocation_inferrer.dart b/pkg/analyzer/lib/src/dart/resolver/invocation_inferrer.dart index fe15873d53f..2c8267935f4 100644 --- a/pkg/analyzer/lib/src/dart/resolver/invocation_inferrer.dart +++ b/pkg/analyzer/lib/src/dart/resolver/invocation_inferrer.dart @@ -61,7 +61,6 @@ class AnnotationInferrer extends FullInvocationInferrer { {required ResolverVisitor resolver, required AnnotationImpl node, required ArgumentListImpl argumentList, - required FunctionType? rawType, required DartType? contextType, required List whyNotPromotedList, required this.constructorName}) @@ -69,7 +68,6 @@ class AnnotationInferrer extends FullInvocationInferrer { resolver: resolver, node: node, argumentList: argumentList, - rawType: rawType, contextType: contextType, whyNotPromotedList: whyNotPromotedList); @@ -113,14 +111,12 @@ abstract class FullInvocationInferrer {required ResolverVisitor resolver, required Node node, required ArgumentListImpl argumentList, - required FunctionType? rawType, required DartType? contextType, required List whyNotPromotedList}) : super( resolver: resolver, node: node, argumentList: argumentList, - rawType: rawType, contextType: contextType, whyNotPromotedList: whyNotPromotedList); @@ -138,9 +134,8 @@ abstract class FullInvocationInferrer CompileTimeErrorCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS_METHOD; @override - DartType resolveInvocation() { + DartType resolveInvocation({required FunctionType? rawType}) { var typeArgumentList = _typeArguments; - var rawType = this.rawType; List? typeArgumentTypes; GenericInferrer? inferrer; @@ -202,7 +197,7 @@ abstract class FullInvocationInferrer } else if (rawType == null || rawType.typeFormals.isEmpty) { typeArgumentTypes = const []; } else { - this.rawType = rawType = getFreshTypeParameters(rawType.typeFormals) + rawType = getFreshTypeParameters(rawType.typeFormals) .applyToFunctionType(rawType); inferrer = resolver.typeSystem.setupGenericTypeInference( @@ -233,7 +228,8 @@ abstract class FullInvocationInferrer resolver.typeSystem, deferredClosures, rawType?.typeFormals.toSet() ?? const {}, - _computeUndeferredParamInfo(parameterMap, deferredClosures)) + _computeUndeferredParamInfo( + rawType, parameterMap, deferredClosures)) .planReconciliationStages()) { if (inferrer != null && !isFirstStage) { substitution = Substitution.fromPairs( @@ -273,6 +269,7 @@ abstract class FullInvocationInferrer /// Computes a list of [_ParamInfo] objects corresponding to the invocation /// parameters that were *not* deferred. List<_ParamInfo> _computeUndeferredParamInfo( + FunctionType? rawType, Map parameterMap, List<_DeferredParamInfo> deferredClosures) { if (rawType == null) return const []; @@ -315,14 +312,12 @@ class FunctionExpressionInvocationInferrer {required ResolverVisitor resolver, required FunctionExpressionInvocationImpl node, required ArgumentListImpl argumentList, - required FunctionType? rawType, required DartType? contextType, required List whyNotPromotedList}) : super._( resolver: resolver, node: node, argumentList: argumentList, - rawType: rawType, contextType: contextType, whyNotPromotedList: whyNotPromotedList); @@ -338,14 +333,12 @@ class InstanceCreationInferrer {required ResolverVisitor resolver, required InstanceCreationExpressionImpl node, required ArgumentListImpl argumentList, - required FunctionType? rawType, required DartType? contextType, required List whyNotPromotedList}) : super._( resolver: resolver, node: node, argumentList: argumentList, - rawType: rawType, contextType: contextType, whyNotPromotedList: whyNotPromotedList); @@ -397,14 +390,12 @@ abstract class InvocationExpressionInferrer< {required ResolverVisitor resolver, required Node node, required ArgumentListImpl argumentList, - required FunctionType? rawType, required DartType? contextType, required List whyNotPromotedList}) : super._( resolver: resolver, node: node, argumentList: argumentList, - rawType: rawType, contextType: contextType, whyNotPromotedList: whyNotPromotedList); @@ -432,18 +423,15 @@ class InvocationInferrer { final ResolverVisitor resolver; final Node node; final ArgumentListImpl argumentList; - FunctionType? rawType; final DartType? contextType; final List whyNotPromotedList; /// Prepares to perform type inference on an invocation expression of type - /// [Node]. [rawType] should be the type of the function the invocation is - /// resolved to (with type arguments not applied yet). + /// [Node]. InvocationInferrer( {required this.resolver, required this.node, required this.argumentList, - required this.rawType, required this.contextType, required this.whyNotPromotedList}); @@ -451,8 +439,10 @@ class InvocationInferrer { /// `identical` (which needs special flow analysis treatment). bool get _isIdentical => false; - /// Performs type inference on the invocation expression. - void resolveInvocation() { + /// Performs type inference on the invocation expression. [rawType] should be + /// the type of the function the invocation is resolved to (with type + /// arguments not applied yet). + void resolveInvocation({required FunctionType? rawType}) { var deferredClosures = _visitArguments( parameterMap: _computeParameterMap(rawType?.parameters ?? const [])); if (deferredClosures != null) { @@ -591,14 +581,12 @@ class MethodInvocationInferrer {required ResolverVisitor resolver, required MethodInvocationImpl node, required ArgumentListImpl argumentList, - required FunctionType? rawType, required DartType? contextType, required List whyNotPromotedList}) : super._( resolver: resolver, node: node, argumentList: argumentList, - rawType: rawType, contextType: contextType, whyNotPromotedList: whyNotPromotedList); diff --git a/pkg/analyzer/lib/src/dart/resolver/method_invocation_resolver.dart b/pkg/analyzer/lib/src/dart/resolver/method_invocation_resolver.dart index 081bb5de47b..e7d3b26bfb3 100644 --- a/pkg/analyzer/lib/src/dart/resolver/method_invocation_resolver.dart +++ b/pkg/analyzer/lib/src/dart/resolver/method_invocation_resolver.dart @@ -332,10 +332,9 @@ class MethodInvocationResolver { resolver: _resolver, node: node, argumentList: node.argumentList, - rawType: rawType is FunctionType ? rawType : null, contextType: contextType, whyNotPromotedList: whyNotPromotedList) - .resolveInvocation(); + .resolveInvocation(rawType: rawType is FunctionType ? rawType : null); _inferenceHelper.recordStaticType(node, staticStaticType, contextType: contextType); } @@ -478,10 +477,9 @@ class MethodInvocationResolver { resolver: _resolver, node: node, argumentList: node.argumentList, - rawType: rawType, whyNotPromotedList: whyNotPromotedList, contextType: contextType) - .resolveInvocation(); + .resolveInvocation(rawType: rawType); } void _resolveReceiverFunctionBounded( @@ -553,10 +551,9 @@ class MethodInvocationResolver { resolver: _resolver, node: node, argumentList: node.argumentList, - rawType: null, contextType: contextType, whyNotPromotedList: whyNotPromotedList) - .resolveInvocation(); + .resolveInvocation(rawType: null); _resolver.errorReporter.reportErrorForNode( HintCode.RECEIVER_OF_TYPE_NEVER, @@ -574,10 +571,9 @@ class MethodInvocationResolver { resolver: _resolver, node: node, argumentList: node.argumentList, - rawType: null, contextType: contextType, whyNotPromotedList: whyNotPromotedList) - .resolveInvocation(); + .resolveInvocation(rawType: null); return; } } diff --git a/pkg/analyzer/lib/src/generated/resolver.dart b/pkg/analyzer/lib/src/generated/resolver.dart index b757ae56aed..0d4d0712df5 100644 --- a/pkg/analyzer/lib/src/generated/resolver.dart +++ b/pkg/analyzer/lib/src/generated/resolver.dart @@ -1545,6 +1545,9 @@ class ResolverVisitor extends ThrowingAstVisitor resolver: this, node: node, argumentList: node.argumentList, + contextType: null, + whyNotPromotedList: whyNotPromotedList) + .resolveInvocation( rawType: receiverContextType == null ? null : FunctionTypeImpl( @@ -1554,10 +1557,7 @@ class ResolverVisitor extends ThrowingAstVisitor null, receiverContextType, ParameterKind.REQUIRED) ], returnType: DynamicTypeImpl.instance, - nullabilitySuffix: NullabilitySuffix.none), - contextType: null, - whyNotPromotedList: whyNotPromotedList) - .resolveInvocation(); + nullabilitySuffix: NullabilitySuffix.none)); extensionResolver.resolveOverride(node, whyNotPromotedList); } @@ -2170,10 +2170,9 @@ class ResolverVisitor extends ThrowingAstVisitor resolver: this, node: node, argumentList: node.argumentList, - rawType: node.staticElement?.type, contextType: null, whyNotPromotedList: whyNotPromotedList) - .resolveInvocation(); + .resolveInvocation(rawType: node.staticElement?.type); checkForArgumentTypesNotAssignableInList( node.argumentList, whyNotPromotedList); } @@ -2280,10 +2279,9 @@ class ResolverVisitor extends ThrowingAstVisitor resolver: this, node: node, argumentList: node.argumentList, - rawType: node.staticElement?.type, contextType: null, whyNotPromotedList: whyNotPromotedList) - .resolveInvocation(); + .resolveInvocation(rawType: node.staticElement?.type); checkForArgumentTypesNotAssignableInList( node.argumentList, whyNotPromotedList); }