@@ -3068,7 +3068,7 @@ class ConstraintSystem {
3068
3068
return nullptr ;
3069
3069
}
3070
3070
3071
- TypeBase* getFavoredType (Expr *E) {
3071
+ TypeBase * getFavoredType (Expr *E) {
3072
3072
assert (E != nullptr );
3073
3073
return this ->FavoredTypes [E];
3074
3074
}
@@ -3082,95 +3082,46 @@ class ConstraintSystem {
3082
3082
// /
3083
3083
// / The side tables are used through the expression type checker to avoid
3084
3084
// / mutating nodes until we know we have successfully type-checked them.
3085
- void setType (ASTNode node, Type type) {
3086
- ASSERT (!node.isNull () && " Cannot set type information on null node" );
3087
- ASSERT (type && " Expected non-null type" );
3088
-
3089
- // Record the type.
3090
- Type &entry = NodeTypes[node];
3091
- Type oldType = entry;
3092
- entry = type;
3093
-
3094
- if (oldType.getPointer () != type.getPointer ()) {
3095
- // Record the fact that we assigned a type to this node.
3096
- if (solverState)
3097
- recordChange (SolverTrail::Change::RecordedNodeType (node, oldType));
3098
- }
3099
- }
3085
+ void setType (ASTNode node, Type type,
3086
+ PreparedOverloadBuilder *preparedOverload=nullptr );
3100
3087
3101
3088
// / Undo the above change.
3102
- void restoreType (ASTNode node, Type oldType) {
3103
- ASSERT (!node.isNull () && " Cannot set type information on null node" );
3104
-
3105
- if (oldType) {
3106
- auto found = NodeTypes.find (node);
3107
- ASSERT (found != NodeTypes.end ());
3108
- found->second = oldType;
3109
- } else {
3110
- bool erased = NodeTypes.erase (node);
3111
- ASSERT (erased);
3112
- }
3113
- }
3089
+ void restoreType (ASTNode node, Type oldType);
3114
3090
3115
3091
// / Check to see if we have a type for a node.
3116
3092
bool hasType (ASTNode node) const {
3117
- assert (!node.isNull () && " Expected non-null node" );
3093
+ ASSERT (!node.isNull () && " Expected non-null node" );
3118
3094
return NodeTypes.count (node) > 0 ;
3119
3095
}
3120
3096
3121
3097
// / Set the type in our type map for a given expression. The side
3122
3098
// / map is used throughout the expression type checker in order to
3123
3099
// / avoid mutating expressions until we know we have successfully
3124
3100
// / type-checked them.
3125
- void setType (const KeyPathExpr *KP, unsigned I, Type T) {
3126
- ASSERT (KP && " Expected non-null key path parameter!" );
3127
- ASSERT (T && " Expected non-null type!" );
3128
-
3129
- Type &entry = KeyPathComponentTypes[{KP, I}];
3130
- Type oldType = entry;
3131
- entry = T;
3101
+ void setType (const KeyPathExpr *KP, unsigned I, Type T);
3132
3102
3133
- if (oldType.getPointer () != T.getPointer ()) {
3134
- if (solverState) {
3135
- recordChange (
3136
- SolverTrail::Change::RecordedKeyPathComponentType (
3137
- KP, I, oldType));
3138
- }
3139
- }
3140
- }
3141
-
3142
- void restoreType (const KeyPathExpr *KP, unsigned I, Type T) {
3143
- ASSERT (KP && " Expected non-null key path parameter!" );
3144
-
3145
- if (T) {
3146
- auto found = KeyPathComponentTypes.find ({KP, I});
3147
- ASSERT (found != KeyPathComponentTypes.end ());
3148
- found->second = T;
3149
- } else {
3150
- bool erased = KeyPathComponentTypes.erase ({KP, I});
3151
- ASSERT (erased);
3152
- }
3153
- }
3103
+ void restoreType (const KeyPathExpr *KP, unsigned I, Type T);
3154
3104
3155
3105
bool hasType (const KeyPathExpr *KP, unsigned I) const {
3156
- assert (KP && " Expected non-null key path parameter!" );
3106
+ ASSERT (KP && " Expected non-null key path parameter!" );
3157
3107
return KeyPathComponentTypes.find (std::make_pair (KP, I))
3158
3108
!= KeyPathComponentTypes.end ();
3159
3109
}
3160
3110
3161
3111
// / Get the type for an node.
3162
3112
Type getType (ASTNode node) const {
3163
- assert (hasType (node) && " Expected type to have been set!" );
3164
- // FIXME: lvalue differences
3165
- // assert((!E->getType() ||
3166
- // E->getType()->isEqual(ExprTypes.find(E)->second)) &&
3167
- // "Mismatched types!");
3168
- return NodeTypes.find (node)->second ;
3113
+ ASSERT (!node.isNull () && " Expected non-null node" );
3114
+ auto found = NodeTypes.find (node);
3115
+ ASSERT (found != NodeTypes.end () && " Expected type to have been set!" );
3116
+ return found->second ;
3169
3117
}
3170
3118
3171
3119
Type getType (const KeyPathExpr *KP, unsigned I) const {
3172
- assert (hasType (KP, I) && " Expected type to have been set!" );
3173
- return KeyPathComponentTypes.find (std::make_pair (KP, I))->second ;
3120
+ ASSERT (KP && " Expected non-null key path parameter!" );
3121
+ auto found = KeyPathComponentTypes.find (std::make_pair (KP, I));
3122
+ ASSERT (found != KeyPathComponentTypes.end () &&
3123
+ " Expected type to have been set!" );
3124
+ return found->second ;
3174
3125
}
3175
3126
3176
3127
// / Retrieve the type of the node, if known.
@@ -3182,11 +3133,6 @@ class ConstraintSystem {
3182
3133
return known->second ;
3183
3134
}
3184
3135
3185
- // / Retrieve type of the given declaration to be used in
3186
- // / constraint system, this is better than calling `getType()`
3187
- // / directly because it accounts of constraint system flags.
3188
- Type getVarType (const VarDecl *var);
3189
-
3190
3136
// / Cache the type of the expression argument and return that same
3191
3137
// / argument.
3192
3138
template <typename T>
@@ -3795,7 +3741,7 @@ class ConstraintSystem {
3795
3741
// / Add a constraint that binds an overload set to a specific choice.
3796
3742
void addBindOverloadConstraint (Type boundTy, OverloadChoice choice,
3797
3743
ConstraintLocator *locator, DeclContext *useDC) {
3798
- resolveOverload (locator, boundTy, choice, useDC ,
3744
+ resolveOverload (choice, useDC, locator, boundTy ,
3799
3745
/* preparedOverload=*/ nullptr );
3800
3746
}
3801
3747
@@ -4437,24 +4383,18 @@ class ConstraintSystem {
4437
4383
FunctionType *adjustFunctionTypeForConcurrency (
4438
4384
FunctionType *fnType, Type baseType, ValueDecl *decl, DeclContext *dc,
4439
4385
unsigned numApplies, bool isMainDispatchQueue,
4440
- ArrayRef<OpenedType> replacements, ConstraintLocatorBuilder locator,
4441
- PreparedOverloadBuilder *preparedOverload);
4386
+ bool openGlobalActorType, ConstraintLocatorBuilder locator);
4442
4387
4443
4388
// / Retrieve the type of a reference to the given value declaration.
4444
4389
// /
4445
4390
// / For references to polymorphic function types, this routine "opens up"
4446
4391
// / the type by replacing each instance of an archetype with a fresh type
4447
4392
// / variable.
4448
4393
// /
4449
- // / \param decl The declarations whose type is being computed.
4450
- // /
4451
4394
// / \returns a description of the type of this declaration reference.
4452
4395
DeclReferenceType getTypeOfReference (
4453
- ValueDecl *decl,
4454
- FunctionRefInfo functionRefInfo,
4455
- ConstraintLocatorBuilder locator,
4456
- DeclContext *useDC,
4457
- PreparedOverloadBuilder *preparedOverload);
4396
+ OverloadChoice choice, DeclContext *useDC, ConstraintLocatorBuilder locator,
4397
+ PreparedOverloadBuilder *preparedOverload);
4458
4398
4459
4399
// / Retrieve the type of a reference to the given value declaration,
4460
4400
// / as a member with a base of the given type.
@@ -4463,15 +4403,10 @@ class ConstraintSystem {
4463
4403
// / this routine "opens up" the type by replacing each instance of a generic
4464
4404
// / parameter with a fresh type variable.
4465
4405
// /
4466
- // / \param isDynamicLookup Indicates that this declaration was found via
4467
- // / dynamic lookup.
4468
- // /
4469
4406
// / \returns a description of the type of this declaration reference.
4470
4407
DeclReferenceType getTypeOfMemberReference (
4471
- Type baseTy, ValueDecl *decl, DeclContext *useDC, bool isDynamicLookup,
4472
- FunctionRefInfo functionRefInfo, ConstraintLocator *locator,
4473
- SmallVectorImpl<OpenedType> *replacements = nullptr ,
4474
- PreparedOverloadBuilder *preparedOverload = nullptr );
4408
+ OverloadChoice choice, DeclContext *useDC, ConstraintLocator *locator,
4409
+ PreparedOverloadBuilder *preparedOverload);
4475
4410
4476
4411
// / Retrieve a list of generic parameter types solver has "opened" (replaced
4477
4412
// / with a type variable) at the given location.
@@ -4483,7 +4418,25 @@ class ConstraintSystem {
4483
4418
}
4484
4419
4485
4420
private:
4486
- DeclReferenceType getTypeOfMemberTypeReference (
4421
+ // / \returns The opened type and the thrown error type.
4422
+ std::pair<Type, Type> getTypeOfReferencePre (
4423
+ OverloadChoice choice, DeclContext *useDC, ConstraintLocatorBuilder locator,
4424
+ PreparedOverloadBuilder *preparedOverload);
4425
+
4426
+ DeclReferenceType getTypeOfReferencePost (
4427
+ OverloadChoice choice, DeclContext *useDC, ConstraintLocatorBuilder locator,
4428
+ Type openedType, Type thrownErrorType);
4429
+
4430
+ // / \returns the opened type and the thrown error type.
4431
+ std::pair<Type, Type> getTypeOfMemberReferencePre (
4432
+ OverloadChoice choice, DeclContext *useDC, ConstraintLocator *locator,
4433
+ PreparedOverloadBuilder *preparedOverload);
4434
+
4435
+ DeclReferenceType getTypeOfMemberReferencePost (
4436
+ OverloadChoice choice, DeclContext *useDC, ConstraintLocator *locator,
4437
+ Type openedType, Type thrownErrorType);
4438
+
4439
+ Type getTypeOfMemberTypeReference (
4487
4440
Type baseObjTy, TypeDecl *typeDecl, ConstraintLocator *locator,
4488
4441
PreparedOverloadBuilder *preparedOverload);
4489
4442
@@ -4513,8 +4466,7 @@ class ConstraintSystem {
4513
4466
// / determine the reference type of the member reference.
4514
4467
Type getMemberReferenceTypeFromOpenedType (
4515
4468
Type type, Type baseObjTy, ValueDecl *value,
4516
- ConstraintLocator *locator, bool hasAppliedSelf, bool isDynamicLookup,
4517
- ArrayRef<OpenedType> replacements);
4469
+ ConstraintLocator *locator, bool hasAppliedSelf, bool isDynamicLookup);
4518
4470
4519
4471
// / Add the constraints needed to bind an overload's type variable.
4520
4472
void bindOverloadType (const SelectedOverload &overload, Type boundType,
@@ -4918,26 +4870,31 @@ class ConstraintSystem {
4918
4870
SelectedOverload choice);
4919
4871
4920
4872
// / Build and allocate a prepared overload in the solver arena.
4921
- PreparedOverload *prepareOverload (ConstraintLocator *locator ,
4922
- OverloadChoice choice ,
4923
- DeclContext *useDC );
4873
+ PreparedOverload *prepareOverload (OverloadChoice choice ,
4874
+ DeclContext *useDC ,
4875
+ ConstraintLocator *locator );
4924
4876
4925
4877
// / Populate the prepared overload with all type variables and constraints
4926
4878
// / that are to be introduced into the constraint system when this choice
4927
4879
// / is taken.
4928
- DeclReferenceType
4929
- prepareOverloadImpl (ConstraintLocator *locator,
4930
- OverloadChoice choice,
4880
+ // /
4881
+ // / Returns a pair consisting of the opened type, and the thrown error type.
4882
+ // /
4883
+ // / FIXME: As a transitional mechanism, if preparedOverload is nullptr, this
4884
+ // / immediately performs all operations.
4885
+ std::pair<Type, Type>
4886
+ prepareOverloadImpl (OverloadChoice choice,
4931
4887
DeclContext *useDC,
4888
+ ConstraintLocator *locator,
4932
4889
PreparedOverloadBuilder *preparedOverload);
4933
4890
4934
4891
void replayChanges (
4935
4892
ConstraintLocator *locator,
4936
4893
PreparedOverload *preparedOverload);
4937
4894
4938
4895
// / Resolve the given overload set to the given choice.
4939
- void resolveOverload (ConstraintLocator *locator, Type boundType ,
4940
- OverloadChoice choice, DeclContext *useDC ,
4896
+ void resolveOverload (OverloadChoice choice, DeclContext *useDC ,
4897
+ ConstraintLocator *locator, Type boundType ,
4941
4898
PreparedOverload *preparedOverload);
4942
4899
4943
4900
// / Simplify a type, by replacing type variables with either their
0 commit comments