@@ -3590,7 +3590,7 @@ static bool generateWrappedPropertyTypeConstraints(
35903590 auto dc = wrappedVar->getInnermostDeclContext ();
35913591
35923592 Type wrappedValueType;
3593- Type wrapperType = initializerType ;
3593+ Type wrapperType;
35943594 auto wrapperAttributes = wrappedVar->getAttachedPropertyWrappers ();
35953595 for (unsigned i : indices (wrapperAttributes)) {
35963596 // FIXME: We should somehow pass an OpenUnboundGenericTypeFn to
@@ -3602,19 +3602,25 @@ static bool generateWrappedPropertyTypeConstraints(
36023602 return true ;
36033603
36043604 auto *typeExpr = wrapperAttributes[i]->getTypeExpr ();
3605- auto *locator = cs.getConstraintLocator (typeExpr, LocatorPathElt::WrappedValue (wrapperType.getPointer ()));
3606- wrapperType = cs.replaceInferableTypesWithTypeVars (rawWrapperType, locator);
3607- cs.setType (typeExpr, wrapperType);
36083605
36093606 if (!wrappedValueType) {
36103607 // Equate the outermost wrapper type to the initializer type.
3608+ auto *locator = cs.getConstraintLocator (typeExpr);
3609+ wrapperType =
3610+ cs.replaceInferableTypesWithTypeVars (rawWrapperType, locator);
36113611 if (initializerType)
36123612 cs.addConstraint (ConstraintKind::Equal, wrapperType, initializerType, locator);
36133613 } else {
36143614 // The former wrappedValue type must be equal to the current wrapper type
3615+ auto *locator = cs.getConstraintLocator (
3616+ typeExpr, LocatorPathElt::WrappedValue (wrapperType.getPointer ()));
3617+ wrapperType =
3618+ cs.replaceInferableTypesWithTypeVars (rawWrapperType, locator);
36153619 cs.addConstraint (ConstraintKind::Equal, wrapperType, wrappedValueType, locator);
36163620 }
36173621
3622+ cs.setType (typeExpr, wrapperType);
3623+
36183624 wrappedValueType = wrapperType->getTypeOfMember (
36193625 dc->getParentModule (), wrapperInfo.valueVar );
36203626 }
0 commit comments