@@ -8,10 +8,7 @@ import 'package:_fe_analyzer_shared/src/type_inference/type_analyzer_operations.
88import 'package:_fe_analyzer_shared/src/type_inference/type_constraint.dart'
99 as shared;
1010import '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;
1311import 'package:kernel/ast.dart' ;
14- import 'package:kernel/src/bounds_checks.dart' ;
1512import 'package:kernel/class_hierarchy.dart'
1613 show ClassHierarchy, ClassHierarchyBase;
1714import '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