From f9c45af68947dbbff83b51cb17bbd200cdd1b4ae Mon Sep 17 00:00:00 2001 From: Paul Berry Date: Fri, 24 Mar 2023 12:25:18 +0000 Subject: [PATCH] Fix nomenclature around upwards/downwards/partial inference to match spec. The spec uses the terms "upwards" vs "downwards" inference to refer to whether type constraints come from a return type or parameter types. Previous to this change the code used the terms "upwards" vs "partial" inference to refer to whether the types being chosen were preliminary (and hence might contain `?`s) or were the final inferred types. This led to confusion; for example the method `downwardInferObjectPatternRequiredType` was calling `upwardsInfer`. This change adjusts the nomenclature so that the methods that choose types are called `choosePreliminaryTypes` and `chooseFinalTypes`, to avoid any confusion with the direction of inference. See discussion here: https://dart-review.googlesource.com/c/sdk/+/290613/comment/894a767c_e269584e/. Change-Id: Ie05dcae027ca82b2ce7e5a57f1846412d5b32d50 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/290901 Reviewed-by: Konstantin Shcheglov Reviewed-by: Chloe Stefantsova Commit-Queue: Paul Berry --- .../src/dart/element/generic_inferrer.dart | 28 +++++++++---------- .../lib/src/dart/element/type_system.dart | 4 +-- .../dart/resolver/applicable_extensions.dart | 2 +- .../resolver/extension_member_resolver.dart | 2 +- .../dart/resolver/invocation_inferrer.dart | 8 +++--- .../dart/resolver/named_type_resolver.dart | 2 +- .../dart/resolver/typed_literal_resolver.dart | 12 ++++---- pkg/analyzer/lib/src/generated/resolver.dart | 2 +- .../dart/element/generic_inferrer_test.dart | 2 +- .../type_inference/inference_visitor.dart | 24 ++++++++-------- .../inference_visitor_base.dart | 10 +++---- .../type_schema_environment.dart | 27 +++++++++--------- .../type_schema_environment_test_base.dart | 6 ++-- .../test/spell_checking_list_code.txt | 1 + 14 files changed, 67 insertions(+), 63 deletions(-) diff --git a/pkg/analyzer/lib/src/dart/element/generic_inferrer.dart b/pkg/analyzer/lib/src/dart/element/generic_inferrer.dart index b857fa9104c..2abc66cda1a 100644 --- a/pkg/analyzer/lib/src/dart/element/generic_inferrer.dart +++ b/pkg/analyzer/lib/src/dart/element/generic_inferrer.dart @@ -112,6 +112,14 @@ class GenericInferrer { TypeProviderImpl get typeProvider => _typeSystem.typeProvider; + /// Performs upwards inference, producing a final set of inferred types that + /// does not contain references to the "unknown type". + List chooseFinalTypes() => tryChooseFinalTypes(failAtError: false)!; + + /// Performs partial (either downwards or horizontal) inference, producing a + /// set of inferred types that may contain references to the "unknown type". + List choosePreliminaryTypes() => _chooseTypes(preliminary: true); + /// Apply an argument constraint, which asserts that the [argument] staticType /// is a subtype of the [parameterType]. void constrainArgument( @@ -177,15 +185,11 @@ class GenericInferrer { _tryMatchSubtypeOf(declaredType, contextType, origin, covariant: true); } - /// Performs partial (either downwards or horizontal) inference, producing a - /// set of inferred types that may contain references to the "unknown type". - List partialInfer() => _chooseTypes(partial: true); - - /// Same as [upwardsInfer], but if [failAtError] is `true` (the default) and - /// inference fails, returns `null` rather than trying to perform error + /// Same as [chooseFinalTypes], but if [failAtError] is `true` (the default) + /// and inference fails, returns `null` rather than trying to perform error /// recovery. - List? tryUpwardsInfer({bool failAtError = true}) { - var inferredTypes = _chooseTypes(partial: false); + List? tryChooseFinalTypes({bool failAtError = true}) { + var inferredTypes = _chooseTypes(preliminary: false); // Check the inferred types against all of the constraints. var knownTypes = {}; var hasErrorReported = false; @@ -298,10 +302,6 @@ class GenericInferrer { return result; } - /// Performs upwards inference, producing a final set of inferred types that - /// does not contain references to the "unknown type". - List upwardsInfer() => tryUpwardsInfer(failAtError: false)!; - /// Check that inferred [typeArguments] satisfy the [typeParameters] bounds. void _checkArgumentsNotMatchingBounds({ required AstNode? errorNode, @@ -423,7 +423,7 @@ class GenericInferrer { /// Computes (or recomputes) a set of [inferredTypes] based on the constraints /// that have been recorded so far. - List _chooseTypes({required bool partial}) { + List _chooseTypes({required bool preliminary}) { var inferredTypes = List.filled( _typeFormals.length, UnknownInferredType.instance); for (int i = 0; i < _typeFormals.length; i++) { @@ -445,7 +445,7 @@ class GenericInferrer { var previouslyInferredType = _typesInferredSoFar[typeParam]; if (previouslyInferredType != null) { inferredTypes[i] = previouslyInferredType; - } else if (partial) { + } else if (preliminary) { var inferredType = _inferTypeParameterFromContext( constraints, extendsClause, isContravariant: typeParam.variance.isContravariant); diff --git a/pkg/analyzer/lib/src/dart/element/type_system.dart b/pkg/analyzer/lib/src/dart/element/type_system.dart index 3adb6dca671..94495a99090 100644 --- a/pkg/analyzer/lib/src/dart/element/type_system.dart +++ b/pkg/analyzer/lib/src/dart/element/type_system.dart @@ -536,7 +536,7 @@ class TypeSystemImpl implements TypeSystem { inferrer.constrainGenericFunctionInContext(fnType, contextType); // Infer and instantiate the resulting type. - return inferrer.upwardsInfer(); + return inferrer.chooseFinalTypes(); } @override @@ -1345,7 +1345,7 @@ class TypeSystemImpl implements TypeSystem { } var inferredTypes = inferrer - .upwardsInfer() + .chooseFinalTypes() .map(_removeBoundsOfGenericFunctionTypes) .toFixedList(); var substitution = Substitution.fromPairs(typeParameters, inferredTypes); diff --git a/pkg/analyzer/lib/src/dart/resolver/applicable_extensions.dart b/pkg/analyzer/lib/src/dart/resolver/applicable_extensions.dart index bf399a3aa2b..26a107252bf 100644 --- a/pkg/analyzer/lib/src/dart/resolver/applicable_extensions.dart +++ b/pkg/analyzer/lib/src/dart/resolver/applicable_extensions.dart @@ -201,7 +201,7 @@ extension NotInstantiatedExtensionsExtensions rawExtendedType, 'extendedType', ); - var inferredTypes = inferrer.tryUpwardsInfer(); + var inferredTypes = inferrer.tryChooseFinalTypes(); if (inferredTypes == null) { continue; } diff --git a/pkg/analyzer/lib/src/dart/resolver/extension_member_resolver.dart b/pkg/analyzer/lib/src/dart/resolver/extension_member_resolver.dart index 6dd7018f784..5ffa72bcefc 100644 --- a/pkg/analyzer/lib/src/dart/resolver/extension_member_resolver.dart +++ b/pkg/analyzer/lib/src/dart/resolver/extension_member_resolver.dart @@ -352,7 +352,7 @@ class ExtensionMemberResolver { element.extendedType, 'extendedType', ); - return inferrer.upwardsInfer(); + return inferrer.chooseFinalTypes(); } } diff --git a/pkg/analyzer/lib/src/dart/resolver/invocation_inferrer.dart b/pkg/analyzer/lib/src/dart/resolver/invocation_inferrer.dart index a1dabaa6757..15517d0cf8d 100644 --- a/pkg/analyzer/lib/src/dart/resolver/invocation_inferrer.dart +++ b/pkg/analyzer/lib/src/dart/resolver/invocation_inferrer.dart @@ -199,8 +199,8 @@ abstract class FullInvocationInferrer genericMetadataIsEnabled: resolver.genericMetadataIsEnabled, ); - substitution = - Substitution.fromPairs(rawType.typeFormals, inferrer.partialInfer()); + substitution = Substitution.fromPairs( + rawType.typeFormals, inferrer.choosePreliminaryTypes()); } List?>? identicalInfo = _isIdentical ? [] : null; @@ -221,7 +221,7 @@ abstract class FullInvocationInferrer .planReconciliationStages()) { if (inferrer != null && !isFirstStage) { substitution = Substitution.fromPairs( - rawType!.typeFormals, inferrer.partialInfer()); + rawType!.typeFormals, inferrer.choosePreliminaryTypes()); } _resolveDeferredFunctionLiterals( deferredFunctionLiterals: stage, @@ -233,7 +233,7 @@ abstract class FullInvocationInferrer } if (inferrer != null) { - typeArgumentTypes = inferrer.upwardsInfer(); + typeArgumentTypes = inferrer.chooseFinalTypes(); } FunctionType? invokeType = typeArgumentTypes != null ? rawType?.instantiate(typeArgumentTypes) diff --git a/pkg/analyzer/lib/src/dart/resolver/named_type_resolver.dart b/pkg/analyzer/lib/src/dart/resolver/named_type_resolver.dart index dc6fd3f8c2b..6657de4e86b 100644 --- a/pkg/analyzer/lib/src/dart/resolver/named_type_resolver.dart +++ b/pkg/analyzer/lib/src/dart/resolver/named_type_resolver.dart @@ -181,7 +181,7 @@ class NamedTypeResolver with ScopeHelpers { contextReturnType: enclosingClass!.thisType, genericMetadataIsEnabled: _genericMetadataIsEnabled, ); - var typeArguments = inferrer.upwardsInfer(); + var typeArguments = inferrer.chooseFinalTypes(); return element.instantiate( typeArguments: typeArguments, nullabilitySuffix: _noneOrStarSuffix, diff --git a/pkg/analyzer/lib/src/dart/resolver/typed_literal_resolver.dart b/pkg/analyzer/lib/src/dart/resolver/typed_literal_resolver.dart index e9ef95961a0..de27813edea 100644 --- a/pkg/analyzer/lib/src/dart/resolver/typed_literal_resolver.dart +++ b/pkg/analyzer/lib/src/dart/resolver/typed_literal_resolver.dart @@ -108,7 +108,7 @@ class TypedLiteralResolver { } else { inferrer = _inferListTypeDownwards(node, contextType: contextType); if (contextType is! UnknownInferredType) { - var typeArguments = inferrer.partialInfer(); + var typeArguments = inferrer.choosePreliminaryTypes(); listType = _typeProvider.listElement.instantiate( typeArguments: typeArguments, nullabilitySuffix: _noneOrStarSuffix); } @@ -142,7 +142,7 @@ class TypedLiteralResolver { } else { inferrer = _inferSetTypeDownwards(node, literalResolution.contextType); if (literalResolution.contextType != null) { - var typeArguments = inferrer.partialInfer(); + var typeArguments = inferrer.choosePreliminaryTypes(); literalType = _typeProvider.setElement.instantiate( typeArguments: typeArguments, nullabilitySuffix: _noneOrStarSuffix); @@ -156,7 +156,7 @@ class TypedLiteralResolver { } else { inferrer = _inferMapTypeDownwards(node, literalResolution.contextType); if (literalResolution.contextType != null) { - var typeArguments = inferrer.partialInfer(); + var typeArguments = inferrer.choosePreliminaryTypes(); literalType = _typeProvider.mapElement.instantiate( typeArguments: typeArguments, nullabilitySuffix: _noneOrStarSuffix); @@ -499,7 +499,7 @@ class TypedLiteralResolver { inferrer.constrainArguments( parameters: parameters, argumentTypes: elementTypes); - var typeArguments = inferrer.upwardsInfer(); + var typeArguments = inferrer.chooseFinalTypes(); return element.instantiate( typeArguments: typeArguments, nullabilitySuffix: _noneOrStarSuffix, @@ -742,7 +742,7 @@ class TypedLiteralResolver { parameters: parameters, argumentTypes: argumentTypes, ); - var typeArguments = inferrer.upwardsInfer(); + var typeArguments = inferrer.chooseFinalTypes(); return element.instantiate( typeArguments: typeArguments, nullabilitySuffix: _noneOrStarSuffix, @@ -776,7 +776,7 @@ class TypedLiteralResolver { } inferrer.constrainArguments( parameters: parameters, argumentTypes: argumentTypes); - var typeArguments = inferrer.upwardsInfer(); + var typeArguments = inferrer.chooseFinalTypes(); return element.instantiate( typeArguments: typeArguments, nullabilitySuffix: _noneOrStarSuffix); } diff --git a/pkg/analyzer/lib/src/generated/resolver.dart b/pkg/analyzer/lib/src/generated/resolver.dart index 4f1ffad3bbb..8227aea5a8f 100644 --- a/pkg/analyzer/lib/src/generated/resolver.dart +++ b/pkg/analyzer/lib/src/generated/resolver.dart @@ -3676,7 +3676,7 @@ class ResolverVisitor extends ThrowingAstVisitor genericMetadataIsEnabled: genericMetadataIsEnabled, ); inferrer.constrainReturnType(declaredType, contextType); - return inferrer.upwardsInfer(); + return inferrer.chooseFinalTypes(); } /// If `expression` should be treated as `expression.call`, inserts an diff --git a/pkg/analyzer/test/src/dart/element/generic_inferrer_test.dart b/pkg/analyzer/test/src/dart/element/generic_inferrer_test.dart index c5668a55140..1e9ac41d1ae 100644 --- a/pkg/analyzer/test/src/dart/element/generic_inferrer_test.dart +++ b/pkg/analyzer/test/src/dart/element/generic_inferrer_test.dart @@ -658,7 +658,7 @@ class GenericFunctionInferenceTest extends AbstractTypeSystemTest { ); inferrer.constrainArguments( parameters: ft.parameters, argumentTypes: arguments); - var typeArguments = inferrer.upwardsInfer(); + var typeArguments = inferrer.chooseFinalTypes(); if (expectError) { expect(listener.errors.map((e) => e.errorCode).toList(), diff --git a/pkg/front_end/lib/src/fasta/type_inference/inference_visitor.dart b/pkg/front_end/lib/src/fasta/type_inference/inference_visitor.dart index 4b3243dcbe7..3fb0fd38457 100644 --- a/pkg/front_end/lib/src/fasta/type_inference/inference_visitor.dart +++ b/pkg/front_end/lib/src/fasta/type_inference/inference_visitor.dart @@ -2580,7 +2580,7 @@ class InferenceVisitorImpl extends InferenceVisitorBase listType, listClass.typeParameters, typeContext, isNonNullableByDefault: isNonNullableByDefault, isConst: node.isConst); - inferredTypes = typeSchemaEnvironment.partialInfer( + inferredTypes = typeSchemaEnvironment.choosePreliminaryTypes( gatherer, listClass.typeParameters, null, isNonNullableByDefault: isNonNullableByDefault); inferredTypeArgument = inferredTypes[0]; @@ -2598,7 +2598,7 @@ class InferenceVisitorImpl extends InferenceVisitorBase } if (inferenceNeeded) { gatherer!.constrainArguments(formalTypes, actualTypes); - inferredTypes = typeSchemaEnvironment.upwardsInfer( + inferredTypes = typeSchemaEnvironment.chooseFinalTypes( gatherer, listClass.typeParameters, inferredTypes!, isNonNullableByDefault: isNonNullableByDefault); if (dataForTesting != null) { @@ -4614,7 +4614,7 @@ class InferenceVisitorImpl extends InferenceVisitorBase mapType, mapClass.typeParameters, typeContext, isNonNullableByDefault: isNonNullableByDefault, isConst: node.isConst); - inferredTypes = typeSchemaEnvironment.partialInfer( + inferredTypes = typeSchemaEnvironment.choosePreliminaryTypes( gatherer, mapClass.typeParameters, null, isNonNullableByDefault: isNonNullableByDefault); inferredKeyType = inferredTypes[0]; @@ -4687,11 +4687,12 @@ class InferenceVisitorImpl extends InferenceVisitorBase setType, coreTypes.setClass.typeParameters, typeContext, isNonNullableByDefault: isNonNullableByDefault, isConst: node.isConst); - List inferredTypesForSet = typeSchemaEnvironment.partialInfer( - gatherer, coreTypes.setClass.typeParameters, null, - isNonNullableByDefault: isNonNullableByDefault); + List inferredTypesForSet = + typeSchemaEnvironment.choosePreliminaryTypes( + gatherer, coreTypes.setClass.typeParameters, null, + isNonNullableByDefault: isNonNullableByDefault); gatherer.constrainArguments(formalTypesForSet, actualTypesForSet); - inferredTypesForSet = typeSchemaEnvironment.upwardsInfer( + inferredTypesForSet = typeSchemaEnvironment.chooseFinalTypes( gatherer, coreTypes.setClass.typeParameters, inferredTypesForSet, isNonNullableByDefault: isNonNullableByDefault); DartType inferredTypeArgument = inferredTypesForSet[0]; @@ -4731,7 +4732,7 @@ class InferenceVisitorImpl extends InferenceVisitorBase NeverType.fromNullability(libraryBuilder.nonNullable), replacement); } gatherer!.constrainArguments(formalTypes, actualTypes); - inferredTypes = typeSchemaEnvironment.upwardsInfer( + inferredTypes = typeSchemaEnvironment.chooseFinalTypes( gatherer, mapClass.typeParameters, inferredTypes!, isNonNullableByDefault: isNonNullableByDefault); if (dataForTesting != null) { @@ -7899,7 +7900,7 @@ class InferenceVisitorImpl extends InferenceVisitorBase setType, setClass.typeParameters, typeContext, isNonNullableByDefault: isNonNullableByDefault, isConst: node.isConst); - inferredTypes = typeSchemaEnvironment.partialInfer( + inferredTypes = typeSchemaEnvironment.choosePreliminaryTypes( gatherer, setClass.typeParameters, null, isNonNullableByDefault: isNonNullableByDefault); inferredTypeArgument = inferredTypes[0]; @@ -7918,7 +7919,7 @@ class InferenceVisitorImpl extends InferenceVisitorBase if (inferenceNeeded) { gatherer!.constrainArguments(formalTypes, actualTypes); - inferredTypes = typeSchemaEnvironment.upwardsInfer( + inferredTypes = typeSchemaEnvironment.chooseFinalTypes( gatherer, setClass.typeParameters, inferredTypes!, isNonNullableByDefault: isNonNullableByDefault); if (dataForTesting != null) { @@ -10914,7 +10915,8 @@ class InferenceVisitorImpl extends InferenceVisitorBase TypeConstraintGatherer gatherer = typeSchemaEnvironment .setupGenericTypeInference(declaredType, typeParameters, contextType, isNonNullableByDefault: isNonNullableByDefault); - return typeSchemaEnvironment.upwardsInfer(gatherer, typeParameters, null, + return typeSchemaEnvironment.chooseFinalTypes( + gatherer, typeParameters, null, isNonNullableByDefault: isNonNullableByDefault); } diff --git a/pkg/front_end/lib/src/fasta/type_inference/inference_visitor_base.dart b/pkg/front_end/lib/src/fasta/type_inference/inference_visitor_base.dart index 1dcd086aea1..6082599e47a 100644 --- a/pkg/front_end/lib/src/fasta/type_inference/inference_visitor_base.dart +++ b/pkg/front_end/lib/src/fasta/type_inference/inference_visitor_base.dart @@ -969,7 +969,7 @@ abstract class InferenceVisitorBase implements InferenceVisitor { .setupGenericTypeInference(null, typeParameters, null, isNonNullableByDefault: libraryBuilder.isNonNullableByDefault); gatherer.constrainArguments([onType], [receiverType]); - inferredTypes = typeSchemaEnvironment.upwardsInfer( + inferredTypes = typeSchemaEnvironment.chooseFinalTypes( gatherer, typeParameters, inferredTypes, isNonNullableByDefault: isNonNullableByDefault); return inferredTypes; @@ -1829,7 +1829,7 @@ abstract class InferenceVisitorBase implements InferenceVisitor { calleeTypeParameters, typeContext, isNonNullableByDefault: isNonNullableByDefault); - inferredTypes = typeSchemaEnvironment.partialInfer( + inferredTypes = typeSchemaEnvironment.choosePreliminaryTypes( gatherer, calleeTypeParameters, null, isNonNullableByDefault: isNonNullableByDefault); substitution = @@ -2006,7 +2006,7 @@ abstract class InferenceVisitorBase implements InferenceVisitor { : const []) .planReconciliationStages()) { if (gatherer != null && !isFirstStage) { - inferredTypes = typeSchemaEnvironment.partialInfer( + inferredTypes = typeSchemaEnvironment.choosePreliminaryTypes( gatherer, calleeTypeParameters, inferredTypes, isNonNullableByDefault: isNonNullableByDefault); substitution = @@ -2113,7 +2113,7 @@ abstract class InferenceVisitorBase implements InferenceVisitor { } if (inferenceNeeded) { - inferredTypes = typeSchemaEnvironment.upwardsInfer( + inferredTypes = typeSchemaEnvironment.chooseFinalTypes( gatherer!, calleeTypeParameters, inferredTypes!, isNonNullableByDefault: isNonNullableByDefault); assert(inferredTypes.every((type) => isKnown(type)), @@ -3699,7 +3699,7 @@ abstract class InferenceVisitorBase implements InferenceVisitor { typeSchemaEnvironment.setupGenericTypeInference( instantiatedType, typeParameters, context, isNonNullableByDefault: isNonNullableByDefault); - inferredTypes = typeSchemaEnvironment.upwardsInfer( + inferredTypes = typeSchemaEnvironment.chooseFinalTypes( gatherer, typeParameters, inferredTypes, isNonNullableByDefault: isNonNullableByDefault); Substitution substitution = diff --git a/pkg/front_end/lib/src/fasta/type_inference/type_schema_environment.dart b/pkg/front_end/lib/src/fasta/type_inference/type_schema_environment.dart index 9959b7c4a5d..cef0a06b949 100644 --- a/pkg/front_end/lib/src/fasta/type_inference/type_schema_environment.dart +++ b/pkg/front_end/lib/src/fasta/type_inference/type_schema_environment.dart @@ -123,13 +123,13 @@ class TypeSchemaEnvironment extends HierarchyBasedTypeEnvironment /// Performs partial (either downwards or horizontal) inference, producing a /// set of inferred types that may contain references to the "unknown type". - List partialInfer( + List choosePreliminaryTypes( TypeConstraintGatherer gatherer, List typeParametersToInfer, List? previouslyInferredTypes, {required bool isNonNullableByDefault}) => _chooseTypes(gatherer, typeParametersToInfer, previouslyInferredTypes, - isNonNullableByDefault: isNonNullableByDefault, partial: true); + isNonNullableByDefault: isNonNullableByDefault, preliminary: true); @override DartType getTypeOfSpecialCasedBinaryOperator(DartType type1, DartType type2, @@ -251,17 +251,18 @@ class TypeSchemaEnvironment extends HierarchyBasedTypeEnvironment /// of types inferred by the last call to this method; it should be a list of /// the same length. /// - /// If [partial] is `true`, then we not in the final pass of inference. This - /// means we are allowed to return `?` to precisely represent an unknown type. + /// If [preliminary] is `true`, then we not in the final pass of inference. + /// This means we are allowed to return `?` to precisely represent an unknown + /// type. /// - /// If [partial] is `false`, then we are in the final pass of inference, and - /// must not conclude `?` for any type formal. + /// If [preliminary] is `false`, then we are in the final pass of inference, + /// and must not conclude `?` for any type formal. List inferTypeFromConstraints( Map constraints, List typeParametersToInfer, List? previouslyInferredTypes, {required bool isNonNullableByDefault, - bool partial = false}) { + bool preliminary = false}) { List inferredTypes = previouslyInferredTypes?.toList(growable: false) ?? new List.filled(typeParametersToInfer.length, const UnknownType()); @@ -278,7 +279,7 @@ class TypeSchemaEnvironment extends HierarchyBasedTypeEnvironment } TypeConstraint constraint = constraints[typeParam]!; - if (partial) { + if (preliminary) { inferredTypes[i] = _inferTypeParameterFromContext( previouslyInferredTypes?[i], constraint, extendsConstraint, isNonNullableByDefault: isNonNullableByDefault, @@ -292,7 +293,7 @@ class TypeSchemaEnvironment extends HierarchyBasedTypeEnvironment } } - if (!partial) { + if (!preliminary) { assert(typeParametersToInfer.length == inferredTypes.length); FreshTypeParameters freshTypeParameters = getFreshTypeParameters(typeParametersToInfer); @@ -493,13 +494,13 @@ class TypeSchemaEnvironment extends HierarchyBasedTypeEnvironment /// Performs upwards inference, producing a final set of inferred types that /// does not contain references to the "unknown type". - List upwardsInfer( + List chooseFinalTypes( TypeConstraintGatherer gatherer, List typeParametersToInfer, List? previouslyInferredTypes, {required bool isNonNullableByDefault}) => _chooseTypes(gatherer, typeParametersToInfer, previouslyInferredTypes, - isNonNullableByDefault: isNonNullableByDefault, partial: false); + isNonNullableByDefault: isNonNullableByDefault, preliminary: false); /// Computes (or recomputes) a set of [inferredTypes] based on the constraints /// that have been recorded so far. @@ -508,14 +509,14 @@ class TypeSchemaEnvironment extends HierarchyBasedTypeEnvironment List typeParametersToInfer, List? previouslyInferredTypes, {required bool isNonNullableByDefault, - required bool partial}) { + required bool preliminary}) { List inferredTypes = inferTypeFromConstraints( gatherer.computeConstraints( isNonNullableByDefault: isNonNullableByDefault), typeParametersToInfer, previouslyInferredTypes, isNonNullableByDefault: isNonNullableByDefault, - partial: partial); + preliminary: preliminary); for (int i = 0; i < inferredTypes.length; i++) { inferredTypes[i] = demoteTypeInLibrary(inferredTypes[i], diff --git a/pkg/front_end/test/fasta/type_inference/type_schema_environment_test_base.dart b/pkg/front_end/test/fasta/type_inference/type_schema_environment_test_base.dart index 0c343b3ea72..72f324f4038 100644 --- a/pkg/front_end/test/fasta/type_inference/type_schema_environment_test_base.dart +++ b/pkg/front_end/test/fasta/type_inference/type_schema_environment_test_base.dart @@ -171,12 +171,12 @@ abstract class TypeSchemaEnvironmentTestBase { returnContextTypeNode, isNonNullableByDefault: isNonNullableByDefault); if (formalTypeNodes == null) { - inferredTypeNodes = typeSchemaEnvironment.partialInfer( + inferredTypeNodes = typeSchemaEnvironment.choosePreliminaryTypes( gatherer, typeParameterNodesToInfer, inferredTypeNodes, isNonNullableByDefault: isNonNullableByDefault); } else { gatherer.constrainArguments(formalTypeNodes, actualTypeNodes!); - inferredTypeNodes = typeSchemaEnvironment.upwardsInfer( + inferredTypeNodes = typeSchemaEnvironment.chooseFinalTypes( gatherer, typeParameterNodesToInfer, inferredTypeNodes!, isNonNullableByDefault: isNonNullableByDefault); } @@ -215,7 +215,7 @@ abstract class TypeSchemaEnvironmentTestBase { [typeParameterNode], inferredTypeNodes, isNonNullableByDefault: isNonNullableByDefault, - partial: downwardsInferPhase); + preliminary: downwardsInferPhase); expect(inferredTypeNodes.single, expectedTypeNode); }); diff --git a/pkg/front_end/test/spell_checking_list_code.txt b/pkg/front_end/test/spell_checking_list_code.txt index 1764688ff1a..b9bcd2f8513 100644 --- a/pkg/front_end/test/spell_checking_list_code.txt +++ b/pkg/front_end/test/spell_checking_list_code.txt @@ -1095,6 +1095,7 @@ preexisted preexisting preferably prefixing +preliminary premark preorder prepares