Skip to content

Commit efe0bf3

Browse files
stereotype441Commit Bot
authored and
Commit Bot
committed
Push logic for constraining argument types into argument visiting loop.
In order to implement dart-lang/language#731 (improved inference for fold etc.), we'll need to gradually accumulate type constraints as we evaluate arguments, and periodically re-do inference; we can't just accumulate all the formal types and actual types and run them through an inference process at the end. This change moves us a step toward that eventuality, by accumulating type constraints after type inference visits each argument, rather than all at once after all arguments have been visited. The total amount of work done is unchanged. Change-Id: I91ed0529cd3142afe4153cac8c25bce3c20f137d Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241800 Reviewed-by: Chloe Stefantsova <[email protected]> Commit-Queue: Paul Berry <[email protected]>
1 parent e63cea6 commit efe0bf3

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2287,8 +2287,7 @@ class TypeInferrerImpl implements TypeInferrer {
22872287
explicitTypeArguments == null &&
22882288
calleeTypeParameters.isNotEmpty;
22892289
bool typeChecksNeeded = !isTopLevel;
2290-
bool useFormalAndActualTypes = inferenceNeeded ||
2291-
typeChecksNeeded ||
2290+
bool useFormalAndActualTypes = typeChecksNeeded ||
22922291
isSpecialCasedBinaryOperator ||
22932292
isSpecialCasedTernaryOperator;
22942293

@@ -2472,6 +2471,7 @@ class TypeInferrerImpl implements TypeInferrer {
24722471
NamedExpression namedArgument = arguments.named[index];
24732472
namedArgument.value = expression..parent = namedArgument;
24742473
}
2474+
gatherer?.tryConstrainLower(formalType, inferredType);
24752475
if (useFormalAndActualTypes) {
24762476
formalTypes!.add(formalType);
24772477
actualTypes!.add(inferredType);
@@ -2574,8 +2574,7 @@ class TypeInferrerImpl implements TypeInferrer {
25742574
}
25752575

25762576
if (inferenceNeeded) {
2577-
gatherer!.constrainArguments(formalTypes!, actualTypes!);
2578-
typeSchemaEnvironment.upwardsInfer(gatherer, calleeTypeParameters,
2577+
typeSchemaEnvironment.upwardsInfer(gatherer!, calleeTypeParameters,
25792578
inferredTypes!, libraryBuilder.library);
25802579
assert(inferredTypes.every((type) => isKnown(type)),
25812580
"Unknown type(s) in inferred types: $inferredTypes.");

0 commit comments

Comments
 (0)