@@ -3590,6 +3590,7 @@ static bool generateWrappedPropertyTypeConstraints(
35903590 auto dc = wrappedVar->getInnermostDeclContext ();
35913591
35923592 Type wrappedValueType;
3593+ Type wrapperType;
35933594 auto wrapperAttributes = wrappedVar->getAttachedPropertyWrappers ();
35943595 for (unsigned i : indices (wrapperAttributes)) {
35953596 // FIXME: We should somehow pass an OpenUnboundGenericTypeFn to
@@ -3601,22 +3602,25 @@ static bool generateWrappedPropertyTypeConstraints(
36013602 return true ;
36023603
36033604 auto *typeExpr = wrapperAttributes[i]->getTypeExpr ();
3604- auto *locator = cs.getConstraintLocator (typeExpr);
3605- auto wrapperType = cs.replaceInferableTypesWithTypeVars (rawWrapperType, locator);
3606- cs.setType (typeExpr, wrapperType);
36073605
36083606 if (!wrappedValueType) {
36093607 // Equate the outermost wrapper type to the initializer type.
3608+ auto *locator = cs.getConstraintLocator (typeExpr);
3609+ wrapperType =
3610+ cs.replaceInferableTypesWithTypeVars (rawWrapperType, locator);
36103611 if (initializerType)
36113612 cs.addConstraint (ConstraintKind::Equal, wrapperType, initializerType, locator);
36123613 } else {
36133614 // 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);
36183620 }
36193621
3622+ cs.setType (typeExpr, wrapperType);
3623+
36203624 wrappedValueType = wrapperType->getTypeOfMember (
36213625 dc->getParentModule (), wrapperInfo.valueVar );
36223626 }
0 commit comments