Skip to content

Commit afdeeeb

Browse files
chloestefantsovaCommit Queue
authored andcommitted
[model] Remove unused remained code after a refactoring
The method `inferTypeFromConstraints` was merged with the shared implementation of chooseTypes in one of the previous refactorings. The method itself wasn't removed by an oversight. This CL addresses the issue. This CL also removes the stub implementation of `chooseTypes` from `MiniAstOperations`, since the shared implementation of `chooseTypes` is already provided and is in effect in all of the type systems, including the one from the mini ast. This is a follow-up for https://dart-review.googlesource.com/c/sdk/+/446660 Change-Id: Ib15e1521444602cd79f093e221bbca81a459a191 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/446901 Commit-Queue: Chloe Stefantsova <[email protected]> Reviewed-by: Paul Berry <[email protected]>
1 parent 649944c commit afdeeeb

File tree

2 files changed

+0
-120
lines changed

2 files changed

+0
-120
lines changed

pkg/_fe_analyzer_shared/test/mini_ast.dart

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3143,21 +3143,6 @@ class MiniAstOperations
31433143
_variance[typeName] = varianceByArgument;
31443144
}
31453145

3146-
@override
3147-
List<SharedType> chooseTypes(
3148-
List<SharedTypeParameter> typeParametersToInfer,
3149-
Map<SharedTypeParameter, MergedTypeConstraint<Var, Type, String, Node>>
3150-
constraints,
3151-
List<SharedType>? previouslyInferredTypes, {
3152-
required bool preliminary,
3153-
required bool inferenceUsingBoundsIsEnabled,
3154-
required TypeConstraintGenerationDataForTesting<Var, Node>? dataForTesting,
3155-
required Node? treeNodeForTesting,
3156-
}) {
3157-
// TODO(paulberry): Implement chooseTypes.
3158-
throw UnimplementedError();
3159-
}
3160-
31613146
@override
31623147
TypeClassification classifyType(SharedTypeView type) {
31633148
if (isSubtypeOfInternal(type.unwrapTypeView<Type>(), Type('Object'))) {

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

Lines changed: 0 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@ import 'package:_fe_analyzer_shared/src/type_inference/type_analyzer_operations.
88
import 'package:_fe_analyzer_shared/src/type_inference/type_constraint.dart'
99
as shared;
1010
import 'package:_fe_analyzer_shared/src/types/shared_type.dart' hide Variance;
11-
import 'package:_fe_analyzer_shared/src/types/shared_type.dart' as shared
12-
show Variance;
1311
import 'package:kernel/ast.dart';
14-
import 'package:kernel/src/bounds_checks.dart';
1512
import 'package:kernel/class_hierarchy.dart'
1613
show ClassHierarchy, ClassHierarchyBase;
1714
import 'package:kernel/core_types.dart' show CoreTypes;
@@ -1075,108 +1072,6 @@ class OperationsCfe
10751072
structuralParameter.defaultType is DynamicType;
10761073
}
10771074

1078-
// Coverage-ignore(suite): Not run.
1079-
/// Use the given [constraints] to substitute for type parameters.
1080-
///
1081-
/// [typeParametersToInfer] is the set of type parameters that should be
1082-
/// substituted for. [previouslyInferredTypes], if present, should be the set
1083-
/// of types inferred by the last call to this method; it should be a list of
1084-
/// the same length.
1085-
///
1086-
/// If [preliminary] is `true`, then we not in the final pass of inference.
1087-
/// This means we are allowed to return `?` to precisely represent an unknown
1088-
/// type.
1089-
///
1090-
/// If [preliminary] is `false`, then we are in the final pass of inference,
1091-
/// and must not conclude `?` for any type formal.
1092-
List<DartType> inferTypeFromConstraints(
1093-
Map<StructuralParameter, MergedTypeConstraint> constraints,
1094-
List<StructuralParameter> typeParametersToInfer,
1095-
List<DartType>? previouslyInferredTypes,
1096-
{bool preliminary = false,
1097-
required InferenceDataForTesting? dataForTesting,
1098-
required bool inferenceUsingBoundsIsEnabled}) {
1099-
List<DartType> inferredTypes =
1100-
previouslyInferredTypes?.toList(growable: false) ??
1101-
new List.filled(typeParametersToInfer.length, const UnknownType());
1102-
1103-
for (int i = 0; i < typeParametersToInfer.length; i++) {
1104-
StructuralParameter typeParam = typeParametersToInfer[i];
1105-
1106-
DartType typeParamBound = typeParam.bound;
1107-
DartType? extendsConstraint;
1108-
if (!isBoundOmitted(typeParam)) {
1109-
extendsConstraint = new FunctionTypeInstantiator.fromIterables(
1110-
typeParametersToInfer, inferredTypes)
1111-
.substitute(typeParamBound);
1112-
}
1113-
1114-
MergedTypeConstraint constraint = constraints[typeParam]!;
1115-
if (preliminary) {
1116-
inferredTypes[i] = inferTypeParameterFromContext(
1117-
previouslyInferredTypes?[i], constraint, extendsConstraint,
1118-
isContravariant:
1119-
typeParam.variance == shared.Variance.contravariant,
1120-
isLegacyCovariant: typeParam.isLegacyCovariant,
1121-
constraints: constraints,
1122-
typeParameterToInfer: typeParam,
1123-
typeParametersToInfer: typeParametersToInfer,
1124-
dataForTesting: dataForTesting,
1125-
inferenceUsingBoundsIsEnabled: inferenceUsingBoundsIsEnabled)
1126-
as DartType;
1127-
} else {
1128-
inferredTypes[i] = inferTypeParameterFromAll(
1129-
previouslyInferredTypes?[i], constraint, extendsConstraint,
1130-
isContravariant:
1131-
typeParam.variance == shared.Variance.contravariant,
1132-
isLegacyCovariant: typeParam.isLegacyCovariant,
1133-
constraints: constraints,
1134-
typeParameterToInfer: typeParam,
1135-
typeParametersToInfer: typeParametersToInfer,
1136-
dataForTesting: dataForTesting,
1137-
inferenceUsingBoundsIsEnabled: inferenceUsingBoundsIsEnabled)
1138-
as DartType;
1139-
}
1140-
}
1141-
1142-
if (!preliminary) {
1143-
assert(typeParametersToInfer.length == inferredTypes.length);
1144-
FreshTypeParametersFromStructuralParameters freshTypeParameters =
1145-
getFreshTypeParametersFromStructuralParameters(typeParametersToInfer);
1146-
List<TypeParameter> helperTypeParameters =
1147-
freshTypeParameters.freshTypeParameters;
1148-
1149-
Map<TypeParameter, DartType> inferredSubstitution = {};
1150-
for (int i = 0; i < helperTypeParameters.length; ++i) {
1151-
if (inferredTypes[i] is UnknownType) {
1152-
inferredSubstitution[helperTypeParameters[i]] =
1153-
new TypeParameterType.withDefaultNullability(
1154-
helperTypeParameters[i]);
1155-
} else {
1156-
assert(isKnownType(new SharedTypeSchemaView(inferredTypes[i])));
1157-
inferredSubstitution[helperTypeParameters[i]] = inferredTypes[i];
1158-
}
1159-
}
1160-
for (int i = 0; i < helperTypeParameters.length; ++i) {
1161-
if (inferredTypes[i] is UnknownType) {
1162-
helperTypeParameters[i].bound =
1163-
substitute(helperTypeParameters[i].bound, inferredSubstitution);
1164-
} else {
1165-
helperTypeParameters[i].bound = inferredTypes[i];
1166-
}
1167-
}
1168-
List<DartType> instantiatedTypes = calculateBounds(
1169-
helperTypeParameters, typeEnvironment.coreTypes.objectClass);
1170-
for (int i = 0; i < instantiatedTypes.length; ++i) {
1171-
if (inferredTypes[i] is UnknownType) {
1172-
inferredTypes[i] = instantiatedTypes[i];
1173-
}
1174-
}
1175-
}
1176-
1177-
return inferredTypes;
1178-
}
1179-
11801075
@override
11811076
DartType substituteTypeFromIterables(
11821077
covariant DartType typeToSubstitute,

0 commit comments

Comments
 (0)