mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[Property Wrappers] Add new contextual type purposes for property wrappers
to produce better diagnostics when there's a 'wrappedValue' type mismatch.
This commit is contained in:
@@ -3893,8 +3893,10 @@ static Type generateWrappedPropertyTypeConstraints(
|
||||
auto *locator =
|
||||
cs.getConstraintLocator(typeRepr, LocatorPathElt::ContextualType());
|
||||
wrapperType = cs.openUnboundGenericTypes(rawWrapperType, locator);
|
||||
cs.addConstraint(ConstraintKind::Equal, wrappedValueType, wrapperType,
|
||||
cs.addConstraint(ConstraintKind::Equal, wrapperType, wrappedValueType,
|
||||
locator);
|
||||
cs.setContextualType(typeRepr, TypeLoc::withoutLoc(wrappedValueType),
|
||||
CTP_ComposedPropertyWrapper);
|
||||
}
|
||||
|
||||
wrappedValueType = wrapperType->getTypeOfMember(
|
||||
@@ -4184,6 +4186,8 @@ bool ConstraintSystem::generateConstraints(
|
||||
|
||||
addConstraint(ConstraintKind::Equal, propertyType, wrappedValueType,
|
||||
getConstraintLocator(wrappedVar, LocatorPathElt::ContextualType()));
|
||||
setContextualType(wrappedVar, TypeLoc::withoutLoc(wrappedValueType),
|
||||
CTP_WrappedProperty);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user