Skip to content

Commit f477549

Browse files
stereotype441Commit Bot
authored andcommitted
Clean up the use of rawType in InvocationInferrer.
In some follow-up work I'm doing with the `InvocationInferrer` class hierarchy to support dart-lang/language#731, I've been getting confused due to the fact that `rawType` is: - a final field in the base class - a non-final local variable in the `FullInvocationInferrer.resolveInvocation` method, which sometimes matches the final field and sometimes doesn't, and - a parameter of some methods in the class hierarchy. This change makes the field non-final and updates it as needed so that it always matches the value of the non-final local variable in `FullInvocationInferrer.resolveInvocation`. (I would have preferred to eliminate the local variable entirely, but it would have led to far too many nuisance null checks). It also eliminates some unnecessary method parameters. Change-Id: I204ef93b5e3433edb9066519ec5d01dd3dfa7f08 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240461 Reviewed-by: Konstantin Shcheglov <scheglov@google.com> Commit-Queue: Paul Berry <paulberry@google.com>
1 parent 240f1c9 commit f477549

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

pkg/analyzer/lib/src/dart/resolver/invocation_inferrer.dart

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ abstract class FullInvocationInferrer<Node extends AstNodeImpl>
173173
} else if (rawType == null || rawType.typeFormals.isEmpty) {
174174
typeArgumentTypes = const <DartType>[];
175175
} else {
176-
rawType = getFreshTypeParameters(rawType.typeFormals)
176+
this.rawType = rawType = getFreshTypeParameters(rawType.typeFormals)
177177
.applyToFunctionType(rawType);
178178

179179
inferrer = resolver.typeSystem.setupGenericTypeInference(
@@ -193,7 +193,6 @@ abstract class FullInvocationInferrer<Node extends AstNodeImpl>
193193
List<EqualityInfo<PromotableElement, DartType>?>? identicalInfo =
194194
_isIdentical ? [] : null;
195195
var deferredClosures = _visitArguments(
196-
rawType: rawType,
197196
identicalInfo: identicalInfo,
198197
substitution: substitution,
199198
inferrer: inferrer);
@@ -206,7 +205,6 @@ abstract class FullInvocationInferrer<Node extends AstNodeImpl>
206205
rawType!.typeFormals, inferrer.partialInfer());
207206
}
208207
_resolveDeferredClosures(
209-
rawType: rawType,
210208
deferredClosures: stage,
211209
identicalInfo: identicalInfo,
212210
substitution: substitution,
@@ -382,7 +380,7 @@ class InvocationInferrer<Node extends AstNodeImpl> {
382380
final ResolverVisitor resolver;
383381
final Node node;
384382
final ArgumentListImpl argumentList;
385-
final FunctionType? rawType;
383+
FunctionType? rawType;
386384
final DartType? contextType;
387385
final List<WhyNotPromotedGetter> whyNotPromotedList;
388386

@@ -403,10 +401,9 @@ class InvocationInferrer<Node extends AstNodeImpl> {
403401

404402
/// Performs type inference on the invocation expression.
405403
void resolveInvocation() {
406-
var deferredClosures = _visitArguments(rawType: rawType);
404+
var deferredClosures = _visitArguments();
407405
if (deferredClosures != null) {
408-
_resolveDeferredClosures(
409-
rawType: rawType, deferredClosures: deferredClosures);
406+
_resolveDeferredClosures(deferredClosures: deferredClosures);
410407
}
411408
}
412409

@@ -429,8 +426,7 @@ class InvocationInferrer<Node extends AstNodeImpl> {
429426

430427
/// Resolves any closures that were deferred by [_visitArguments].
431428
void _resolveDeferredClosures(
432-
{required FunctionType? rawType,
433-
required Iterable<_DeferredClosure> deferredClosures,
429+
{required Iterable<_DeferredClosure> deferredClosures,
434430
List<EqualityInfo<PromotableElement, DartType>?>? identicalInfo,
435431
Substitution? substitution,
436432
GenericInferrer? inferrer}) {
@@ -465,8 +461,7 @@ class InvocationInferrer<Node extends AstNodeImpl> {
465461
/// be deferred due to the `inference-update-1` feature, a list of them is
466462
/// returned.
467463
List<_DeferredClosure>? _visitArguments(
468-
{required FunctionType? rawType,
469-
List<EqualityInfo<PromotableElement, DartType>?>? identicalInfo,
464+
{List<EqualityInfo<PromotableElement, DartType>?>? identicalInfo,
470465
Substitution? substitution,
471466
GenericInferrer? inferrer}) {
472467
assert(whyNotPromotedList.isEmpty);

0 commit comments

Comments
 (0)