@@ -3602,16 +3602,8 @@ static Expr *generateConstraintsFor(ConstraintSystem &cs, Expr *expr,
3602
3602
return result;
3603
3603
}
3604
3604
3605
- // / Generate constraints to produce the wrapped value type given the property
3606
- // / that has an attached property wrapper.
3607
- // /
3608
- // / \param initializerType The type of the adjusted initializer, which
3609
- // / initializes the underlying storage variable.
3610
- // / \param wrappedVar The property that has a property wrapper.
3611
- // / \returns the type of the property.
3612
- static bool generateWrappedPropertyTypeConstraints (
3613
- ConstraintSystem &cs, Type initializerType, VarDecl *wrappedVar,
3614
- Type propertyType) {
3605
+ bool ConstraintSystem::generateWrappedPropertyTypeConstraints (
3606
+ VarDecl *wrappedVar, Type initializerType, Type propertyType) {
3615
3607
auto dc = wrappedVar->getInnermostDeclContext ();
3616
3608
3617
3609
Type wrappedValueType;
@@ -3630,33 +3622,33 @@ static bool generateWrappedPropertyTypeConstraints(
3630
3622
3631
3623
if (!wrappedValueType) {
3632
3624
// Equate the outermost wrapper type to the initializer type.
3633
- auto *locator = cs. getConstraintLocator (typeExpr);
3625
+ auto *locator = getConstraintLocator (typeExpr);
3634
3626
wrapperType =
3635
- cs. replaceInferableTypesWithTypeVars (rawWrapperType, locator);
3627
+ replaceInferableTypesWithTypeVars (rawWrapperType, locator);
3636
3628
if (initializerType)
3637
- cs. addConstraint (ConstraintKind::Equal, wrapperType, initializerType, locator);
3629
+ addConstraint (ConstraintKind::Equal, wrapperType, initializerType, locator);
3638
3630
} else {
3639
3631
// The former wrappedValue type must be equal to the current wrapper type
3640
- auto *locator = cs. getConstraintLocator (
3632
+ auto *locator = getConstraintLocator (
3641
3633
typeExpr, LocatorPathElt::WrappedValue (wrapperType));
3642
3634
wrapperType =
3643
- cs. replaceInferableTypesWithTypeVars (rawWrapperType, locator);
3644
- cs. addConstraint (ConstraintKind::Equal, wrapperType, wrappedValueType, locator);
3635
+ replaceInferableTypesWithTypeVars (rawWrapperType, locator);
3636
+ addConstraint (ConstraintKind::Equal, wrapperType, wrappedValueType, locator);
3645
3637
}
3646
3638
3647
- cs. setType (typeExpr, wrapperType);
3639
+ setType (typeExpr, wrapperType);
3648
3640
3649
3641
wrappedValueType = wrapperType->getTypeOfMember (
3650
3642
dc->getParentModule (), wrapperInfo.valueVar );
3651
3643
}
3652
3644
3653
3645
// The property type must be equal to the wrapped value type
3654
- cs. addConstraint (
3646
+ addConstraint (
3655
3647
ConstraintKind::Equal, propertyType, wrappedValueType,
3656
- cs. getConstraintLocator (
3648
+ getConstraintLocator (
3657
3649
wrappedVar, LocatorPathElt::ContextualType (CTP_WrappedProperty)));
3658
- cs. setContextualType (wrappedVar, TypeLoc::withoutLoc (wrappedValueType),
3659
- CTP_WrappedProperty);
3650
+ setContextualType (wrappedVar, TypeLoc::withoutLoc (wrappedValueType),
3651
+ CTP_WrappedProperty);
3660
3652
return false ;
3661
3653
}
3662
3654
@@ -3675,8 +3667,8 @@ static bool generateInitPatternConstraints(
3675
3667
return true ;
3676
3668
3677
3669
if (auto wrappedVar = target.getInitializationWrappedVar ())
3678
- return generateWrappedPropertyTypeConstraints (
3679
- cs , cs.getType (target.getAsExpr ()), wrappedVar , patternType);
3670
+ return cs. generateWrappedPropertyTypeConstraints (
3671
+ wrappedVar , cs.getType (target.getAsExpr ()), patternType);
3680
3672
3681
3673
if (!patternType->is <OpaqueTypeArchetypeType>()) {
3682
3674
// Add a conversion constraint between the types.
@@ -3968,7 +3960,7 @@ bool ConstraintSystem::generateConstraints(
3968
3960
return true ;
3969
3961
3970
3962
return generateWrappedPropertyTypeConstraints (
3971
- * this , /* initializerType=*/ Type (), wrappedVar , propertyType);
3963
+ wrappedVar , /* initializerType=*/ Type (), propertyType);
3972
3964
} else {
3973
3965
auto pattern = target.getAsUninitializedVar ();
3974
3966
auto locator = getConstraintLocator (
@@ -4158,7 +4150,7 @@ ConstraintSystem::applyPropertyWrapperToParameter(
4158
4150
4159
4151
initKind = PropertyWrapperInitKind::ProjectedValue;
4160
4152
} else {
4161
- generateWrappedPropertyTypeConstraints (* this , wrapperType, param , paramType);
4153
+ generateWrappedPropertyTypeConstraints (param , wrapperType, paramType);
4162
4154
initKind = PropertyWrapperInitKind::WrappedValue;
4163
4155
}
4164
4156
0 commit comments