Skip to content

Commit 475a6fa

Browse files
chloestefantsovaCommit Queue
authored andcommitted
[model] Remove 'topType' parameter from solveTypeConstraint
The parameter is a remnant of the support for non-Null Safe code. The removal of the parameter is a step towards the unification between TypeSchemaEnvironment.solveTypeConstraint in the CFE and GenericInferrer._chooseTypeFromConstraint in the Analyzer. Part of #54902 Change-Id: Ie7efe25591eaff5cdd34c4fffdcd772f94040c28 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/422721 Reviewed-by: Paul Berry <[email protected]> Commit-Queue: Chloe Stefantsova <[email protected]>
1 parent 3464724 commit 475a6fa

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

pkg/front_end/lib/src/type_inference/type_schema_environment.dart

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -344,9 +344,7 @@ class TypeSchemaEnvironment extends HierarchyBasedTypeEnvironment
344344
/// type parameter which means we choose the upper bound rather than the
345345
/// lower bound for normally covariant type parameters.
346346
DartType solveTypeConstraint(MergedTypeConstraint constraint,
347-
{required DartType topType,
348-
bool grounded = false,
349-
bool isContravariant = false}) {
347+
{bool grounded = false, bool isContravariant = false}) {
350348
if (!isContravariant) {
351349
// Prefer the known bound, if any.
352350
if (isKnown(constraint.lower.unwrapTypeSchemaView())) {
@@ -366,7 +364,7 @@ class TypeSchemaEnvironment extends HierarchyBasedTypeEnvironment
366364
} else if (constraint.upper is! UnknownType) {
367365
return grounded
368366
? greatestClosure(constraint.upper.unwrapTypeSchemaView(),
369-
topType: topType)
367+
topType: coreTypes.objectNullableRawType)
370368
: constraint.upper.unwrapTypeSchemaView();
371369
} else {
372370
return const UnknownType();
@@ -387,7 +385,7 @@ class TypeSchemaEnvironment extends HierarchyBasedTypeEnvironment
387385
// Coverage-ignore-block(suite): Not run.
388386
return grounded
389387
? greatestClosure(constraint.upper.unwrapTypeSchemaView(),
390-
topType: topType)
388+
topType: coreTypes.objectNullableRawType)
391389
: constraint.upper.unwrapTypeSchemaView();
392390
} else if (constraint.lower is! UnknownType) {
393391
return grounded
@@ -494,9 +492,7 @@ class TypeSchemaEnvironment extends HierarchyBasedTypeEnvironment
494492
}
495493

496494
return solveTypeConstraint(constraint,
497-
topType: coreTypes.objectNullableRawType,
498-
grounded: true,
499-
isContravariant: isContravariant);
495+
grounded: true, isContravariant: isContravariant);
500496
}
501497

502498
DartType _inferTypeParameterFromContext(DartType? typeFromPreviousInference,
@@ -517,8 +513,7 @@ class TypeSchemaEnvironment extends HierarchyBasedTypeEnvironment
517513
return typeFromPreviousInference;
518514
}
519515

520-
DartType t = solveTypeConstraint(constraint,
521-
topType: coreTypes.objectNullableRawType);
516+
DartType t = solveTypeConstraint(constraint);
522517
if (!isKnown(t)) {
523518
return t;
524519
}
@@ -553,8 +548,7 @@ class TypeSchemaEnvironment extends HierarchyBasedTypeEnvironment
553548
constraint = constraint.clone();
554549
constraint.mergeInTypeSchemaUpper(
555550
new SharedTypeSchemaView(extendsConstraint), operations);
556-
return solveTypeConstraint(constraint,
557-
topType: coreTypes.objectNullableRawType);
551+
return solveTypeConstraint(constraint);
558552
}
559553

560554
return t;

pkg/front_end/test/type_inference/type_schema_environment_test_base.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ abstract class TypeSchemaEnvironmentTestBase {
6868
{required bool grounded}) {
6969
expect(
7070
typeSchemaEnvironment.solveTypeConstraint(parseConstraint(constraint),
71-
topType: coreTypes.objectNullableRawType, grounded: grounded),
71+
grounded: grounded),
7272
parseType(expected));
7373
}
7474

0 commit comments

Comments
 (0)