@@ -3590,6 +3590,7 @@ static bool generateWrappedPropertyTypeConstraints(
3590
3590
auto dc = wrappedVar->getInnermostDeclContext ();
3591
3591
3592
3592
Type wrappedValueType;
3593
+ Type wrapperType;
3593
3594
auto wrapperAttributes = wrappedVar->getAttachedPropertyWrappers ();
3594
3595
for (unsigned i : indices (wrapperAttributes)) {
3595
3596
// FIXME: We should somehow pass an OpenUnboundGenericTypeFn to
@@ -3601,22 +3602,25 @@ static bool generateWrappedPropertyTypeConstraints(
3601
3602
return true ;
3602
3603
3603
3604
auto *typeExpr = wrapperAttributes[i]->getTypeExpr ();
3604
- auto *locator = cs.getConstraintLocator (typeExpr);
3605
- auto wrapperType = cs.replaceInferableTypesWithTypeVars (rawWrapperType, locator);
3606
- cs.setType (typeExpr, wrapperType);
3607
3605
3608
3606
if (!wrappedValueType) {
3609
3607
// Equate the outermost wrapper type to the initializer type.
3608
+ auto *locator = cs.getConstraintLocator (typeExpr);
3609
+ wrapperType =
3610
+ cs.replaceInferableTypesWithTypeVars (rawWrapperType, locator);
3610
3611
if (initializerType)
3611
3612
cs.addConstraint (ConstraintKind::Equal, wrapperType, initializerType, locator);
3612
3613
} else {
3613
3614
// The former wrappedValue type must be equal to the current wrapper type
3614
- cs.addConstraint (ConstraintKind::Equal, wrapperType, wrappedValueType,
3615
- cs.getConstraintLocator (locator, LocatorPathElt::ContextualType ()));
3616
- cs.setContextualType (typeExpr, TypeLoc::withoutLoc (wrappedValueType),
3617
- CTP_ComposedPropertyWrapper);
3615
+ auto *locator = cs.getConstraintLocator (
3616
+ typeExpr, LocatorPathElt::WrappedValue (wrapperType));
3617
+ wrapperType =
3618
+ cs.replaceInferableTypesWithTypeVars (rawWrapperType, locator);
3619
+ cs.addConstraint (ConstraintKind::Equal, wrapperType, wrappedValueType, locator);
3618
3620
}
3619
3621
3622
+ cs.setType (typeExpr, wrapperType);
3623
+
3620
3624
wrappedValueType = wrapperType->getTypeOfMember (
3621
3625
dc->getParentModule (), wrapperInfo.valueVar );
3622
3626
}
0 commit comments