@@ -64,6 +64,7 @@ namespace constraints {
64
64
65
65
class ConstraintSystem ;
66
66
class SyntacticElementTarget ;
67
+ struct PreparedOverload ;
67
68
68
69
} // end namespace constraints
69
70
@@ -2211,6 +2212,8 @@ class ConstraintSystem {
2211
2212
unsigned CountDisjunctions = 0 ;
2212
2213
2213
2214
private:
2215
+ bool PreparingOverload = false ;
2216
+
2214
2217
// / A constraint that has failed along the current solver path.
2215
2218
// / Do not set directly, call \c recordFailedConstraint instead.
2216
2219
Constraint *failedConstraint = nullptr ;
@@ -2752,6 +2755,7 @@ class ConstraintSystem {
2752
2755
SolverState *solverState = nullptr ;
2753
2756
2754
2757
void recordChange (SolverTrail::Change change) {
2758
+ ASSERT (!PreparingOverload);
2755
2759
solverState->Trail .recordChange (change);
2756
2760
}
2757
2761
@@ -2920,15 +2924,15 @@ class ConstraintSystem {
2920
2924
SolverTrail *getTrail () const {
2921
2925
return solverState ? &solverState->Trail : nullptr ;
2922
2926
}
2923
-
2924
- // / Add a new type variable that was already created.
2925
- void addTypeVariable (TypeVariableType *typeVar);
2926
2927
2927
2928
// / Add a constraint from the subscript base to the root of the key
2928
2929
// / path literal to the constraint system.
2929
2930
void addKeyPathApplicationRootConstraint (Type root, ConstraintLocatorBuilder locator);
2930
2931
2931
2932
public:
2933
+ // / Add a new type variable that was already created.
2934
+ void addTypeVariable (TypeVariableType *typeVar);
2935
+
2932
2936
// / Lookup for a member with the given name which is in the given base type.
2933
2937
// /
2934
2938
// / This routine caches the results of member lookups in the top constraint
@@ -2949,7 +2953,9 @@ class ConstraintSystem {
2949
2953
2950
2954
// / Create a new type variable.
2951
2955
TypeVariableType *createTypeVariable (ConstraintLocator *locator,
2952
- unsigned options);
2956
+ unsigned options,
2957
+ PreparedOverload *preparedOverload
2958
+ = nullptr );
2953
2959
2954
2960
// / Retrieve the set of active type variables.
2955
2961
ArrayRef<TypeVariableType *> getTypeVariables () const {
@@ -3407,7 +3413,8 @@ class ConstraintSystem {
3407
3413
3408
3414
// / Update OpenedExistentials and record a change in the trail.
3409
3415
void recordOpenedExistentialType (ConstraintLocator *locator,
3410
- ExistentialArchetypeType *opened);
3416
+ ExistentialArchetypeType *opened,
3417
+ PreparedOverload *preparedOverload = nullptr );
3411
3418
3412
3419
// / Retrieve the generic environment for the opened element of a given pack
3413
3420
// / expansion, or \c nullptr if no environment was recorded yet.
@@ -3614,7 +3621,8 @@ class ConstraintSystem {
3614
3621
3615
3622
// / Log and record the application of the fix. Return true iff any
3616
3623
// / subsequent solution would be worse than the best known solution.
3617
- bool recordFix (ConstraintFix *fix, unsigned impact = 1 );
3624
+ bool recordFix (ConstraintFix *fix, unsigned impact = 1 ,
3625
+ PreparedOverload *preparedOverload = nullptr );
3618
3626
3619
3627
void recordPotentialHole (TypeVariableType *typeVar);
3620
3628
void recordAnyTypeVarAsPotentialHole (Type type);
@@ -3689,12 +3697,14 @@ class ConstraintSystem {
3689
3697
// / Add a constraint to the constraint system.
3690
3698
void addConstraint (ConstraintKind kind, Type first, Type second,
3691
3699
ConstraintLocatorBuilder locator,
3692
- bool isFavored = false );
3700
+ bool isFavored = false ,
3701
+ PreparedOverload *preparedOverload = nullptr );
3693
3702
3694
3703
// / Add a requirement as a constraint to the constraint system.
3695
3704
void addConstraint (Requirement req, ConstraintLocatorBuilder locator,
3696
3705
bool isFavored,
3697
- bool prohibitNonisolatedConformance);
3706
+ bool prohibitNonisolatedConformance,
3707
+ PreparedOverload *preparedOverload = nullptr );
3698
3708
3699
3709
void addApplicationConstraint (
3700
3710
FunctionType *appliedFn, Type calleeType,
@@ -4308,7 +4318,8 @@ class ConstraintSystem {
4308
4318
// / \returns The opened type.
4309
4319
Type openUnboundGenericType (GenericTypeDecl *decl, Type parentTy,
4310
4320
ConstraintLocatorBuilder locator,
4311
- bool isTypeResolution);
4321
+ bool isTypeResolution,
4322
+ PreparedOverload *preparedOverload = nullptr );
4312
4323
4313
4324
// / Replace placeholder types with fresh type variables, and unbound generic
4314
4325
// / types with bound generic types whose generic args are fresh type
@@ -4318,7 +4329,9 @@ class ConstraintSystem {
4318
4329
// /
4319
4330
// / \returns The converted type.
4320
4331
Type replaceInferableTypesWithTypeVars (Type type,
4321
- ConstraintLocatorBuilder locator);
4332
+ ConstraintLocatorBuilder locator,
4333
+ PreparedOverload *preparedOverload
4334
+ = nullptr );
4322
4335
4323
4336
// / "Open" the given type by replacing any occurrences of generic
4324
4337
// / parameter types and dependent member types with fresh type variables.
@@ -4329,7 +4342,8 @@ class ConstraintSystem {
4329
4342
// /
4330
4343
// / \returns The opened type, or \c type if there are no archetypes in it.
4331
4344
Type openType (Type type, ArrayRef<OpenedType> replacements,
4332
- ConstraintLocatorBuilder locator);
4345
+ ConstraintLocatorBuilder locator,
4346
+ PreparedOverload *preparedOverload);
4333
4347
4334
4348
// / "Open" an opaque archetype type, similar to \c openType.
4335
4349
Type openOpaqueType (OpaqueTypeArchetypeType *type,
@@ -4345,11 +4359,14 @@ class ConstraintSystem {
4345
4359
// / aforementioned variable via special constraints.
4346
4360
Type openPackExpansionType (PackExpansionType *expansion,
4347
4361
ArrayRef<OpenedType> replacements,
4348
- ConstraintLocatorBuilder locator);
4362
+ ConstraintLocatorBuilder locator,
4363
+ PreparedOverload *preparedOverload);
4349
4364
4350
4365
// / Update OpenedPackExpansionTypes and record a change in the trail.
4351
4366
void recordOpenedPackExpansionType (PackExpansionType *expansion,
4352
- TypeVariableType *expansionVar);
4367
+ TypeVariableType *expansionVar,
4368
+ PreparedOverload *preparedOverload
4369
+ = nullptr );
4353
4370
4354
4371
// / Undo the above change.
4355
4372
void removeOpenedPackExpansionType (PackExpansionType *expansion) {
@@ -4374,26 +4391,30 @@ class ConstraintSystem {
4374
4391
FunctionType *openFunctionType (AnyFunctionType *funcType,
4375
4392
ConstraintLocatorBuilder locator,
4376
4393
SmallVectorImpl<OpenedType> &replacements,
4377
- DeclContext *outerDC);
4394
+ DeclContext *outerDC,
4395
+ PreparedOverload *preparedOverload);
4378
4396
4379
4397
// / Open the generic parameter list and its requirements,
4380
4398
// / creating type variables for each of the type parameters.
4381
4399
void openGeneric (DeclContext *outerDC,
4382
4400
GenericSignature signature,
4383
4401
ConstraintLocatorBuilder locator,
4384
- SmallVectorImpl<OpenedType> &replacements);
4402
+ SmallVectorImpl<OpenedType> &replacements,
4403
+ PreparedOverload *preparedOverload);
4385
4404
4386
4405
// / Open the generic parameter list creating type variables for each of the
4387
4406
// / type parameters.
4388
4407
void openGenericParameters (DeclContext *outerDC,
4389
4408
GenericSignature signature,
4390
4409
SmallVectorImpl<OpenedType> &replacements,
4391
- ConstraintLocatorBuilder locator);
4410
+ ConstraintLocatorBuilder locator,
4411
+ PreparedOverload *preparedOverload);
4392
4412
4393
4413
// / Open a generic parameter into a type variable and record
4394
4414
// / it in \c replacements.
4395
4415
TypeVariableType *openGenericParameter (GenericTypeParamType *parameter,
4396
- ConstraintLocatorBuilder locator);
4416
+ ConstraintLocatorBuilder locator,
4417
+ PreparedOverload *preparedOverload);
4397
4418
4398
4419
// / Given generic signature open its generic requirements,
4399
4420
// / using substitution function, and record them in the
@@ -4402,7 +4423,8 @@ class ConstraintSystem {
4402
4423
GenericSignature signature,
4403
4424
bool skipProtocolSelfConstraint,
4404
4425
ConstraintLocatorBuilder locator,
4405
- llvm::function_ref<Type(Type)> subst);
4426
+ llvm::function_ref<Type(Type)> subst,
4427
+ PreparedOverload *preparedOverload);
4406
4428
4407
4429
// Record the given requirement in the constraint system.
4408
4430
void openGenericRequirement (DeclContext *outerDC,
@@ -4411,17 +4433,20 @@ class ConstraintSystem {
4411
4433
const Requirement &requirement,
4412
4434
bool skipProtocolSelfConstraint,
4413
4435
ConstraintLocatorBuilder locator,
4414
- llvm::function_ref<Type(Type)> subst);
4436
+ llvm::function_ref<Type(Type)> subst,
4437
+ PreparedOverload *preparedOverload);
4415
4438
4416
4439
// / Update OpenedTypes and record a change in the trail.
4417
4440
void recordOpenedType (
4418
- ConstraintLocator *locator, ArrayRef<OpenedType> openedTypes);
4441
+ ConstraintLocator *locator, ArrayRef<OpenedType> openedTypes,
4442
+ PreparedOverload *preparedOverload = nullptr );
4419
4443
4420
4444
// / Record the set of opened types for the given locator.
4421
4445
void recordOpenedTypes (
4422
4446
ConstraintLocatorBuilder locator,
4423
- SmallVectorImpl<OpenedType> &replacements,
4424
- bool fixmeAllowDuplicates=false );
4447
+ const SmallVectorImpl<OpenedType> &replacements,
4448
+ PreparedOverload *preparedOverload = nullptr ,
4449
+ bool fixmeAllowDuplicates = false );
4425
4450
4426
4451
// / Check whether the given type conforms to the given protocol and if
4427
4452
// / so return a valid conformance reference.
@@ -4432,7 +4457,8 @@ class ConstraintSystem {
4432
4457
FunctionType *adjustFunctionTypeForConcurrency (
4433
4458
FunctionType *fnType, Type baseType, ValueDecl *decl, DeclContext *dc,
4434
4459
unsigned numApplies, bool isMainDispatchQueue,
4435
- ArrayRef<OpenedType> replacements, ConstraintLocatorBuilder locator);
4460
+ ArrayRef<OpenedType> replacements, ConstraintLocatorBuilder locator,
4461
+ PreparedOverload *preparedOverload);
4436
4462
4437
4463
// / Retrieve the type of a reference to the given value declaration.
4438
4464
// /
@@ -4447,7 +4473,8 @@ class ConstraintSystem {
4447
4473
ValueDecl *decl,
4448
4474
FunctionRefInfo functionRefInfo,
4449
4475
ConstraintLocatorBuilder locator,
4450
- DeclContext *useDC);
4476
+ DeclContext *useDC,
4477
+ PreparedOverload *preparedOverload);
4451
4478
4452
4479
// / Return the type-of-reference of the given value.
4453
4480
// /
@@ -4488,7 +4515,8 @@ class ConstraintSystem {
4488
4515
DeclReferenceType getTypeOfMemberReference (
4489
4516
Type baseTy, ValueDecl *decl, DeclContext *useDC, bool isDynamicLookup,
4490
4517
FunctionRefInfo functionRefInfo, ConstraintLocator *locator,
4491
- SmallVectorImpl<OpenedType> *replacements = nullptr );
4518
+ SmallVectorImpl<OpenedType> *replacements = nullptr ,
4519
+ PreparedOverload *preparedOverload = nullptr );
4492
4520
4493
4521
// / Retrieve a list of generic parameter types solver has "opened" (replaced
4494
4522
// / with a type variable) at the given location.
@@ -5307,13 +5335,20 @@ class ConstraintSystem {
5307
5335
// / Matches a wrapped or projected value parameter type to its backing
5308
5336
// / property wrapper type by applying the property wrapper.
5309
5337
TypeMatchResult applyPropertyWrapperToParameter (
5310
- Type wrapperType, Type paramType, ParamDecl *param, Identifier argLabel,
5311
- ConstraintKind matchKind, ConstraintLocator *locator,
5312
- ConstraintLocator *calleeLocator);
5338
+ Type wrapperType,
5339
+ Type paramType,
5340
+ ParamDecl *param,
5341
+ Identifier argLabel,
5342
+ ConstraintKind matchKind,
5343
+ ConstraintLocator *locator,
5344
+ ConstraintLocator *calleeLocator,
5345
+ PreparedOverload *preparedOverload = nullptr );
5313
5346
5314
5347
// / Used by applyPropertyWrapperToParameter() to update appliedPropertyWrappers
5315
5348
// / and record a change in the trail.
5316
- void applyPropertyWrapper (Expr *anchor, AppliedPropertyWrapper applied);
5349
+ void applyPropertyWrapper (Expr *anchor,
5350
+ AppliedPropertyWrapper applied,
5351
+ PreparedOverload *preparedOverload = nullptr );
5317
5352
5318
5353
// / Undo the above change.
5319
5354
void removePropertyWrapper (Expr *anchor);
0 commit comments