[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:
Holly Borla
2020-07-01 19:42:01 -07:00
parent 238637408c
commit f555bfefc9
8 changed files with 35 additions and 3 deletions

View File

@@ -613,6 +613,10 @@ Optional<Diag<Type, Type>> GenericArgumentsMismatchFailure::getDiagnosticFor(
return diag::cannot_convert_subscript_assign;
case CTP_Condition:
return diag::cannot_convert_condition_value;
case CTP_WrappedProperty:
return diag::wrapped_value_mismatch;
case CTP_ComposedPropertyWrapper:
return diag::composed_property_wrapper_mismatch;
case CTP_ThrowStmt:
case CTP_ForEachStmt:
@@ -2206,6 +2210,8 @@ getContextualNilDiagnostic(ContextualTypePurpose CTP) {
case CTP_ThrowStmt:
case CTP_ForEachStmt:
case CTP_YieldByReference:
case CTP_WrappedProperty:
case CTP_ComposedPropertyWrapper:
return None;
case CTP_EnumCaseRawValue:
@@ -2904,6 +2910,11 @@ ContextualFailure::getDiagnosticFor(ContextualTypePurpose context,
case CTP_Condition:
return diag::cannot_convert_condition_value;
case CTP_WrappedProperty:
return diag::wrapped_value_mismatch;
case CTP_ComposedPropertyWrapper:
return diag::composed_property_wrapper_mismatch;
case CTP_ThrowStmt:
case CTP_ForEachStmt:
case CTP_Unused: