Skip to content

Commit 150e8cb

Browse files
chloestefantsovaCommit Queue
authored andcommitted
[cfe] Upate pre-Null Safe naming in the CFE
Change-Id: I45e8dc703ce7810e6df5a328b3829dc86a128792 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/436241 Reviewed-by: Johnni Winther <[email protected]> Commit-Queue: Chloe Stefantsova <[email protected]>
1 parent 986af56 commit 150e8cb

18 files changed

+192
-228
lines changed

pkg/front_end/lib/src/kernel/combined_member_signature.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ abstract class CombinedMemberSignatureBase {
356356
DartType signatureTypeParameterBound =
357357
instantiator.substitute(signatureTypeParameters[i].bound);
358358
if (!_types
359-
.performNullabilityAwareMutualSubtypesCheck(
359+
.performMutualSubtypesCheck(
360360
typeParameterBound, signatureTypeParameterBound)
361361
.isSuccess()) {
362362
return null;

pkg/front_end/lib/src/source/source_class_builder.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1573,7 +1573,7 @@ class SourceClassBuilder extends ClassBuilderImpl
15731573
}
15741574
DartType computedBound = substitution.substituteType(interfaceBound);
15751575
if (!types
1576-
.performNullabilityAwareMutualSubtypesCheck(
1576+
.performMutualSubtypesCheck(
15771577
declaredBound, computedBound)
15781578
.isSuccess()) {
15791579
reportInvalidOverride(

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ class _AsyncClosureContext implements ClosureContext {
472472
..parent = statement;
473473
} else if (flattenedExpressionType is! VoidType &&
474474
!inferrer.typeSchemaEnvironment
475-
.performNullabilityAwareSubtypeCheck(
475+
.performSubtypeCheck(
476476
flattenedExpressionType, emittedValueType!)
477477
.isSuccess()) {
478478
// It is a compile-time error if s is `return e;`, flatten(S) is not

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ import 'type_schema_environment.dart'
5959
show
6060
getNamedParameterType,
6161
getPositionalParameterType,
62-
TypeParameterEliminator,
62+
AllTypeParameterEliminator,
6363
TypeSchemaEnvironment;
6464

6565
/// Given a [FunctionExpression], computes a set whose elements consist of (a)
@@ -880,8 +880,8 @@ abstract class InferenceVisitorBase implements InferenceVisitor {
880880
);
881881
}
882882

883-
IsSubtypeOf isDirectSubtypeResult = typeSchemaEnvironment
884-
.performNullabilityAwareSubtypeCheck(expressionType, contextType);
883+
IsSubtypeOf isDirectSubtypeResult =
884+
typeSchemaEnvironment.performSubtypeCheck(expressionType, contextType);
885885
bool isDirectlyAssignable = isDirectSubtypeResult.isSuccess();
886886
if (isDirectlyAssignable) {
887887
return new AssignabilityResult(
@@ -894,7 +894,7 @@ abstract class InferenceVisitorBase implements InferenceVisitor {
894894
bool isIndirectlyAssignable = expressionType is DynamicType;
895895
if (!isIndirectlyAssignable) {
896896
if (typeSchemaEnvironment
897-
.performNullabilityAwareSubtypeCheck(
897+
.performSubtypeCheck(
898898
expressionType,
899899
contextType.withDeclaredNullability(Nullability.nullable),
900900
)
@@ -1843,7 +1843,7 @@ abstract class InferenceVisitorBase implements InferenceVisitor {
18431843
TypeConstraintGatherer? gatherer;
18441844
if (inferenceNeeded) {
18451845
if (isConst) {
1846-
typeContext = new TypeParameterEliminator(
1846+
typeContext = new AllTypeParameterEliminator(
18471847
bottomType,
18481848
coreTypes.objectNullableRawType,
18491849
).substituteType(typeContext);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -875,7 +875,7 @@ class PromotedCacheableExpression
875875
Expression result = _expression.createExpression(typeEnvironment,
876876
effects: effects, inCacheInitializer: inCacheInitializer);
877877
if (!typeEnvironment
878-
.performNullabilityAwareSubtypeCheck(
878+
.performSubtypeCheck(
879879
_expression.getType(typeEnvironment), _promotedType)
880880
.isSuccess() ||
881881
(_promotedType is! DynamicType &&

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,22 @@ mixin TypeSchemaStandardBounds on StandardBounds {
2525
}
2626

2727
@override
28-
DartType getNullabilityAwareStandardLowerBoundInternal(
28+
DartType getStandardLowerBoundInternal(
2929
DartType type1, DartType type2) {
3030
// - We add the axiom that `DOWN(T, _) == T` and the symmetric version.
3131
if (type1 is UnknownType) return type2;
3232
if (type2 is UnknownType) return type1;
3333

34-
return super.getNullabilityAwareStandardLowerBoundInternal(type1, type2);
34+
return super.getStandardLowerBoundInternal(type1, type2);
3535
}
3636

3737
@override
38-
DartType getNullabilityAwareStandardUpperBoundInternal(
38+
DartType getStandardUpperBoundInternal(
3939
DartType type1, DartType type2) {
4040
// - We add the axiom that `UP(T, _) == T` and the symmetric version.
4141
if (type1 is UnknownType) return type2;
4242
if (type2 is UnknownType) return type1;
4343

44-
return super.getNullabilityAwareStandardUpperBoundInternal(type1, type2);
44+
return super.getStandardUpperBoundInternal(type1, type2);
4545
}
4646
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,7 @@ class OperationsCfe
719719
bool isAssignableTo(SharedTypeView fromType, SharedTypeView toType) {
720720
if (fromType is DynamicType) return true;
721721
return typeEnvironment
722-
.performNullabilityAwareSubtypeCheck(
722+
.performSubtypeCheck(
723723
fromType.unwrapTypeView(), toType.unwrapTypeView())
724724
.isSuccess();
725725
}
@@ -981,15 +981,15 @@ class OperationsCfe
981981
@override
982982
DartType greatestClosureOfTypeInternal(
983983
DartType type, List<SharedTypeParameter> typeParametersToEliminate) {
984-
return new NullabilityAwareFreeTypeParameterEliminator(
984+
return new FreeTypeParameterEliminator(
985985
coreTypes: typeEnvironment.coreTypes)
986986
.eliminateToGreatest(type);
987987
}
988988

989989
@override
990990
DartType leastClosureOfTypeInternal(
991991
DartType type, List<SharedTypeParameter> typeParametersToEliminate) {
992-
return new NullabilityAwareFreeTypeParameterEliminator(
992+
return new FreeTypeParameterEliminator(
993993
coreTypes: typeEnvironment.coreTypes)
994994
.eliminateToLeast(type);
995995
}

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

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,7 @@ class TypeSchemaEnvironment extends HierarchyBasedTypeEnvironment
248248
}
249249

250250
@override
251-
IsSubtypeOf performNullabilityAwareSubtypeCheck(
252-
DartType subtype, DartType supertype) {
251+
IsSubtypeOf performSubtypeCheck(DartType subtype, DartType supertype) {
253252
if (subtype is UnknownType) return const IsSubtypeOf.success();
254253

255254
DartType unwrappedSupertype = supertype;
@@ -259,7 +258,7 @@ class TypeSchemaEnvironment extends HierarchyBasedTypeEnvironment
259258
if (unwrappedSupertype is UnknownType) {
260259
return const IsSubtypeOf.success();
261260
}
262-
return super.performNullabilityAwareSubtypeCheck(subtype, supertype);
261+
return super.performSubtypeCheck(subtype, supertype);
263262
}
264263

265264
// TODO(johnniwinther): Should [context] be non-nullable?
@@ -309,9 +308,9 @@ class TypeSchemaEnvironment extends HierarchyBasedTypeEnvironment
309308

310309
if (!isEmptyContext(returnContextType)) {
311310
if (isConst) {
312-
returnContextType = new NullabilityAwareFreeTypeParameterEliminator(
313-
coreTypes: coreTypes)
314-
.eliminateToLeast(returnContextType!);
311+
returnContextType =
312+
new FreeTypeParameterEliminator(coreTypes: coreTypes)
313+
.eliminateToLeast(returnContextType!);
315314
}
316315
gatherer.tryConstrainUpper(declaredReturnType!, returnContextType!,
317316
treeNodeForTesting: treeNodeForTesting);
@@ -548,11 +547,11 @@ class TypeSchemaEnvironment extends HierarchyBasedTypeEnvironment
548547
}
549548
}
550549

551-
class TypeParameterEliminator extends Substitution {
550+
class AllTypeParameterEliminator extends Substitution {
552551
final DartType bottomType;
553552
final DartType topType;
554553

555-
TypeParameterEliminator(this.bottomType, this.topType);
554+
AllTypeParameterEliminator(this.bottomType, this.topType);
556555

557556
@override
558557
DartType getSubstitute(TypeParameter parameter, bool upperBound) {

pkg/front_end/test/type_inference/type_schema_environment_test_base.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ abstract class TypeSchemaEnvironmentTestBase {
9999
void checkIsSubtype(String subtype, String supertype) {
100100
expect(
101101
typeSchemaEnvironment
102-
.performNullabilityAwareSubtypeCheck(
102+
.performSubtypeCheck(
103103
parseType(subtype), parseType(supertype))
104104
.isSuccess(),
105105
isTrue);
@@ -108,7 +108,7 @@ abstract class TypeSchemaEnvironmentTestBase {
108108
void checkIsNotSubtype(String subtype, String supertype) {
109109
expect(
110110
typeSchemaEnvironment
111-
.performNullabilityAwareSubtypeCheck(
111+
.performSubtypeCheck(
112112
parseType(subtype), parseType(supertype))
113113
.isSuccess(),
114114
isFalse);

pkg/front_end/test/types/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ To collect new data for a benchmark, follow these steps:
1717
`pkg/compiler/lib/src/dart2js.dart`.
1818

1919
2. Modify `pkg/kernel/lib/src/types.dart` as described in the method
20-
`SubtypeTester._collect_performNullabilityAwareSubtypeCheck`.
20+
`SubtypeTester._collect_performSubtypeCheck`.
2121

2222
3. Compile the program using CFE, for example:
2323

0 commit comments

Comments
 (0)