@@ -64,7 +64,11 @@ namespace constraints {
64
64
65
65
class ConstraintSystem ;
66
66
class SyntacticElementTarget ;
67
- struct PreparedOverload ;
67
+
68
+ // PreparedOverload.h
69
+ struct DeclReferenceType ;
70
+ class PreparedOverload ;
71
+ struct PreparedOverloadBuilder ;
68
72
69
73
} // end namespace constraints
70
74
@@ -2143,34 +2147,6 @@ struct ClosureIsolatedByPreconcurrency {
2143
2147
bool operator ()(const ClosureExpr *expr) const ;
2144
2148
};
2145
2149
2146
- // / Describes the type produced when referencing a declaration.
2147
- struct DeclReferenceType {
2148
- // / The "opened" type, which is the type of the declaration where any
2149
- // / generic parameters have been replaced with type variables.
2150
- // /
2151
- // / The mapping from generic parameters to type variables will have been
2152
- // / recorded by \c recordOpenedTypes when this type is produced.
2153
- Type openedType;
2154
-
2155
- // / The opened type, after performing contextual type adjustments such as
2156
- // / removing concurrency-related annotations for a `@preconcurrency`
2157
- // / operation.
2158
- Type adjustedOpenedType;
2159
-
2160
- // / The type of the reference, based on the original opened type. This is the
2161
- // / type that the expression used to form the declaration reference would
2162
- // / have if no adjustments had been applied.
2163
- Type referenceType;
2164
-
2165
- // / The type of the reference, which is the adjusted opened type after
2166
- // / (e.g.) applying the base of a member access. This is the type of the
2167
- // / expression used to form the declaration reference.
2168
- Type adjustedReferenceType;
2169
-
2170
- // / The type that could be thrown by accessing this declaration.
2171
- Type thrownErrorTypeOnAccess;
2172
- };
2173
-
2174
2150
// / Describes a system of constraints on type variables, the
2175
2151
// / solution of which assigns concrete types to each of the type variables.
2176
2152
// / Constraint systems are typically generated given an (untyped) expression.
@@ -2954,7 +2930,7 @@ class ConstraintSystem {
2954
2930
// / Create a new type variable.
2955
2931
TypeVariableType *createTypeVariable (ConstraintLocator *locator,
2956
2932
unsigned options,
2957
- PreparedOverload *preparedOverload
2933
+ PreparedOverloadBuilder *preparedOverload
2958
2934
= nullptr );
2959
2935
2960
2936
// / Retrieve the set of active type variables.
@@ -3414,7 +3390,8 @@ class ConstraintSystem {
3414
3390
// / Update OpenedExistentials and record a change in the trail.
3415
3391
void recordOpenedExistentialType (ConstraintLocator *locator,
3416
3392
ExistentialArchetypeType *opened,
3417
- PreparedOverload *preparedOverload = nullptr );
3393
+ PreparedOverloadBuilder *preparedOverload
3394
+ = nullptr );
3418
3395
3419
3396
// / Retrieve the generic environment for the opened element of a given pack
3420
3397
// / expansion, or \c nullptr if no environment was recorded yet.
@@ -3622,7 +3599,7 @@ class ConstraintSystem {
3622
3599
// / Log and record the application of the fix. Return true iff any
3623
3600
// / subsequent solution would be worse than the best known solution.
3624
3601
bool recordFix (ConstraintFix *fix, unsigned impact = 1 ,
3625
- PreparedOverload *preparedOverload = nullptr );
3602
+ PreparedOverloadBuilder *preparedOverload = nullptr );
3626
3603
3627
3604
void recordPotentialHole (TypeVariableType *typeVar);
3628
3605
void recordAnyTypeVarAsPotentialHole (Type type);
@@ -3698,13 +3675,13 @@ class ConstraintSystem {
3698
3675
void addConstraint (ConstraintKind kind, Type first, Type second,
3699
3676
ConstraintLocatorBuilder locator,
3700
3677
bool isFavored = false ,
3701
- PreparedOverload *preparedOverload = nullptr );
3678
+ PreparedOverloadBuilder *preparedOverload = nullptr );
3702
3679
3703
3680
// / Add a requirement as a constraint to the constraint system.
3704
3681
void addConstraint (Requirement req, ConstraintLocatorBuilder locator,
3705
3682
bool isFavored,
3706
3683
bool prohibitNonisolatedConformance,
3707
- PreparedOverload *preparedOverload = nullptr );
3684
+ PreparedOverloadBuilder *preparedOverload = nullptr );
3708
3685
3709
3686
void addApplicationConstraint (
3710
3687
FunctionType *appliedFn, Type calleeType,
@@ -3814,9 +3791,9 @@ class ConstraintSystem {
3814
3791
3815
3792
// / Add a constraint that binds an overload set to a specific choice.
3816
3793
void addBindOverloadConstraint (Type boundTy, OverloadChoice choice,
3817
- ConstraintLocator *locator,
3818
- DeclContext * useDC) {
3819
- resolveOverload (locator, boundTy, choice, useDC );
3794
+ ConstraintLocator *locator, DeclContext *useDC) {
3795
+ resolveOverload (locator, boundTy, choice, useDC,
3796
+ /* preparedOverload= */ nullptr );
3820
3797
}
3821
3798
3822
3799
// / Add a value member constraint to the constraint system.
@@ -4319,7 +4296,7 @@ class ConstraintSystem {
4319
4296
Type openUnboundGenericType (GenericTypeDecl *decl, Type parentTy,
4320
4297
ConstraintLocatorBuilder locator,
4321
4298
bool isTypeResolution,
4322
- PreparedOverload *preparedOverload = nullptr );
4299
+ PreparedOverloadBuilder *preparedOverload = nullptr );
4323
4300
4324
4301
// / Replace placeholder types with fresh type variables, and unbound generic
4325
4302
// / types with bound generic types whose generic args are fresh type
@@ -4330,7 +4307,7 @@ class ConstraintSystem {
4330
4307
// / \returns The converted type.
4331
4308
Type replaceInferableTypesWithTypeVars (Type type,
4332
4309
ConstraintLocatorBuilder locator,
4333
- PreparedOverload *preparedOverload
4310
+ PreparedOverloadBuilder *preparedOverload
4334
4311
= nullptr );
4335
4312
4336
4313
// / "Open" the given type by replacing any occurrences of generic
@@ -4343,7 +4320,7 @@ class ConstraintSystem {
4343
4320
// / \returns The opened type, or \c type if there are no archetypes in it.
4344
4321
Type openType (Type type, ArrayRef<OpenedType> replacements,
4345
4322
ConstraintLocatorBuilder locator,
4346
- PreparedOverload *preparedOverload);
4323
+ PreparedOverloadBuilder *preparedOverload);
4347
4324
4348
4325
// / "Open" an opaque archetype type, similar to \c openType.
4349
4326
Type openOpaqueType (OpaqueTypeArchetypeType *type,
@@ -4360,12 +4337,12 @@ class ConstraintSystem {
4360
4337
Type openPackExpansionType (PackExpansionType *expansion,
4361
4338
ArrayRef<OpenedType> replacements,
4362
4339
ConstraintLocatorBuilder locator,
4363
- PreparedOverload *preparedOverload);
4340
+ PreparedOverloadBuilder *preparedOverload);
4364
4341
4365
4342
// / Update OpenedPackExpansionTypes and record a change in the trail.
4366
4343
void recordOpenedPackExpansionType (PackExpansionType *expansion,
4367
4344
TypeVariableType *expansionVar,
4368
- PreparedOverload *preparedOverload
4345
+ PreparedOverloadBuilder *preparedOverload
4369
4346
= nullptr );
4370
4347
4371
4348
// / Undo the above change.
@@ -4392,29 +4369,29 @@ class ConstraintSystem {
4392
4369
ConstraintLocatorBuilder locator,
4393
4370
SmallVectorImpl<OpenedType> &replacements,
4394
4371
DeclContext *outerDC,
4395
- PreparedOverload *preparedOverload);
4372
+ PreparedOverloadBuilder *preparedOverload);
4396
4373
4397
4374
// / Open the generic parameter list and its requirements,
4398
4375
// / creating type variables for each of the type parameters.
4399
4376
void openGeneric (DeclContext *outerDC,
4400
4377
GenericSignature signature,
4401
4378
ConstraintLocatorBuilder locator,
4402
4379
SmallVectorImpl<OpenedType> &replacements,
4403
- PreparedOverload *preparedOverload);
4380
+ PreparedOverloadBuilder *preparedOverload);
4404
4381
4405
4382
// / Open the generic parameter list creating type variables for each of the
4406
4383
// / type parameters.
4407
4384
void openGenericParameters (DeclContext *outerDC,
4408
4385
GenericSignature signature,
4409
4386
SmallVectorImpl<OpenedType> &replacements,
4410
4387
ConstraintLocatorBuilder locator,
4411
- PreparedOverload *preparedOverload);
4388
+ PreparedOverloadBuilder *preparedOverload);
4412
4389
4413
4390
// / Open a generic parameter into a type variable and record
4414
4391
// / it in \c replacements.
4415
4392
TypeVariableType *openGenericParameter (GenericTypeParamType *parameter,
4416
4393
ConstraintLocatorBuilder locator,
4417
- PreparedOverload *preparedOverload);
4394
+ PreparedOverloadBuilder *preparedOverload);
4418
4395
4419
4396
// / Given generic signature open its generic requirements,
4420
4397
// / using substitution function, and record them in the
@@ -4424,7 +4401,7 @@ class ConstraintSystem {
4424
4401
bool skipProtocolSelfConstraint,
4425
4402
ConstraintLocatorBuilder locator,
4426
4403
llvm::function_ref<Type(Type)> subst,
4427
- PreparedOverload *preparedOverload);
4404
+ PreparedOverloadBuilder *preparedOverload);
4428
4405
4429
4406
// Record the given requirement in the constraint system.
4430
4407
void openGenericRequirement (DeclContext *outerDC,
@@ -4434,18 +4411,18 @@ class ConstraintSystem {
4434
4411
bool skipProtocolSelfConstraint,
4435
4412
ConstraintLocatorBuilder locator,
4436
4413
llvm::function_ref<Type(Type)> subst,
4437
- PreparedOverload *preparedOverload);
4414
+ PreparedOverloadBuilder *preparedOverload);
4438
4415
4439
4416
// / Update OpenedTypes and record a change in the trail.
4440
4417
void recordOpenedType (
4441
4418
ConstraintLocator *locator, ArrayRef<OpenedType> openedTypes,
4442
- PreparedOverload *preparedOverload = nullptr );
4419
+ PreparedOverloadBuilder *preparedOverload = nullptr );
4443
4420
4444
4421
// / Record the set of opened types for the given locator.
4445
4422
void recordOpenedTypes (
4446
4423
ConstraintLocatorBuilder locator,
4447
4424
const SmallVectorImpl<OpenedType> &replacements,
4448
- PreparedOverload *preparedOverload = nullptr ,
4425
+ PreparedOverloadBuilder *preparedOverload = nullptr ,
4449
4426
bool fixmeAllowDuplicates = false );
4450
4427
4451
4428
// / Check whether the given type conforms to the given protocol and if
@@ -4458,7 +4435,7 @@ class ConstraintSystem {
4458
4435
FunctionType *fnType, Type baseType, ValueDecl *decl, DeclContext *dc,
4459
4436
unsigned numApplies, bool isMainDispatchQueue,
4460
4437
ArrayRef<OpenedType> replacements, ConstraintLocatorBuilder locator,
4461
- PreparedOverload *preparedOverload);
4438
+ PreparedOverloadBuilder *preparedOverload);
4462
4439
4463
4440
// / Retrieve the type of a reference to the given value declaration.
4464
4441
// /
@@ -4474,7 +4451,7 @@ class ConstraintSystem {
4474
4451
FunctionRefInfo functionRefInfo,
4475
4452
ConstraintLocatorBuilder locator,
4476
4453
DeclContext *useDC,
4477
- PreparedOverload *preparedOverload);
4454
+ PreparedOverloadBuilder *preparedOverload);
4478
4455
4479
4456
// / Return the type-of-reference of the given value.
4480
4457
// /
@@ -4516,7 +4493,7 @@ class ConstraintSystem {
4516
4493
Type baseTy, ValueDecl *decl, DeclContext *useDC, bool isDynamicLookup,
4517
4494
FunctionRefInfo functionRefInfo, ConstraintLocator *locator,
4518
4495
SmallVectorImpl<OpenedType> *replacements = nullptr ,
4519
- PreparedOverload *preparedOverload = nullptr );
4496
+ PreparedOverloadBuilder *preparedOverload = nullptr );
4520
4497
4521
4498
// / Retrieve a list of generic parameter types solver has "opened" (replaced
4522
4499
// / with a type variable) at the given location.
@@ -4929,9 +4906,28 @@ class ConstraintSystem {
4929
4906
void recordResolvedOverload (ConstraintLocator *locator,
4930
4907
SelectedOverload choice);
4931
4908
4909
+ // / Build and allocate a prepared overload in the solver arena.
4910
+ PreparedOverload *prepareOverload (ConstraintLocator *locator,
4911
+ OverloadChoice choice,
4912
+ DeclContext *useDC);
4913
+
4914
+ // / Populate the prepared overload with all type variables and constraints
4915
+ // / that are to be introduced into the constraint system when this choice
4916
+ // / is taken.
4917
+ DeclReferenceType
4918
+ prepareOverloadImpl (ConstraintLocator *locator,
4919
+ OverloadChoice choice,
4920
+ DeclContext *useDC,
4921
+ PreparedOverloadBuilder *preparedOverload);
4922
+
4923
+ void replayChanges (
4924
+ ConstraintLocator *locator,
4925
+ PreparedOverload *preparedOverload);
4926
+
4932
4927
// / Resolve the given overload set to the given choice.
4933
4928
void resolveOverload (ConstraintLocator *locator, Type boundType,
4934
- OverloadChoice choice, DeclContext *useDC);
4929
+ OverloadChoice choice, DeclContext *useDC,
4930
+ PreparedOverload *preparedOverload);
4935
4931
4936
4932
// / Simplify a type, by replacing type variables with either their
4937
4933
// / fixed types (if available) or their representatives.
@@ -5342,13 +5338,13 @@ class ConstraintSystem {
5342
5338
ConstraintKind matchKind,
5343
5339
ConstraintLocator *locator,
5344
5340
ConstraintLocator *calleeLocator,
5345
- PreparedOverload *preparedOverload = nullptr );
5341
+ PreparedOverloadBuilder *preparedOverload = nullptr );
5346
5342
5347
5343
// / Used by applyPropertyWrapperToParameter() to update appliedPropertyWrappers
5348
5344
// / and record a change in the trail.
5349
5345
void applyPropertyWrapper (Expr *anchor,
5350
5346
AppliedPropertyWrapper applied,
5351
- PreparedOverload *preparedOverload = nullptr );
5347
+ PreparedOverloadBuilder *preparedOverload = nullptr );
5352
5348
5353
5349
// / Undo the above change.
5354
5350
void removePropertyWrapper (Expr *anchor);
0 commit comments