mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 12:24:24 +00:00
Push logic for constraining argument types into argument visiting loop.
In order to implement https://github.com/dart-lang/language/issues/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 <cstefantsova@google.com> Commit-Queue: Paul Berry <paulberry@google.com>
This commit is contained in:
parent
e63cea6634
commit
efe0bf3ec5
1 changed files with 3 additions and 4 deletions
|
@ -2287,8 +2287,7 @@ class TypeInferrerImpl implements TypeInferrer {
|
|||
explicitTypeArguments == null &&
|
||||
calleeTypeParameters.isNotEmpty;
|
||||
bool typeChecksNeeded = !isTopLevel;
|
||||
bool useFormalAndActualTypes = inferenceNeeded ||
|
||||
typeChecksNeeded ||
|
||||
bool useFormalAndActualTypes = typeChecksNeeded ||
|
||||
isSpecialCasedBinaryOperator ||
|
||||
isSpecialCasedTernaryOperator;
|
||||
|
||||
|
@ -2472,6 +2471,7 @@ class TypeInferrerImpl implements TypeInferrer {
|
|||
NamedExpression namedArgument = arguments.named[index];
|
||||
namedArgument.value = expression..parent = namedArgument;
|
||||
}
|
||||
gatherer?.tryConstrainLower(formalType, inferredType);
|
||||
if (useFormalAndActualTypes) {
|
||||
formalTypes!.add(formalType);
|
||||
actualTypes!.add(inferredType);
|
||||
|
@ -2574,8 +2574,7 @@ class TypeInferrerImpl implements TypeInferrer {
|
|||
}
|
||||
|
||||
if (inferenceNeeded) {
|
||||
gatherer!.constrainArguments(formalTypes!, actualTypes!);
|
||||
typeSchemaEnvironment.upwardsInfer(gatherer, calleeTypeParameters,
|
||||
typeSchemaEnvironment.upwardsInfer(gatherer!, calleeTypeParameters,
|
||||
inferredTypes!, libraryBuilder.library);
|
||||
assert(inferredTypes.every((type) => isKnown(type)),
|
||||
"Unknown type(s) in inferred types: $inferredTypes.");
|
||||
|
|
Loading…
Reference in a new issue