[Diagnostics] Improve the diagnostic for invalid pointer conversion for an autoclosure result type.

Add constraint fix `AllowAutoClosurePointerConversion` and corresponding diagnostic
`AutoClosurePointerConversionFailure`. When we discover that we're trying to do an
inout-to-pointer conversion in `matchTypes`, add the constraint fix, which tries to do the
conversion as if the pointer type is a regular function argument.
This commit is contained in:
Holly Borla
2019-08-02 14:09:30 -07:00
parent 2cfcdf49dc
commit e76f5f1d0b
7 changed files with 96 additions and 10 deletions

View File

@@ -1978,6 +1978,14 @@ bool AutoClosureForwardingFailure::diagnoseAsError() {
return true;
}
bool AutoClosurePointerConversionFailure::diagnoseAsError() {
auto *anchor = getAnchor();
auto diagnostic = diag::invalid_autoclosure_pointer_conversion;
emitDiagnostic(anchor->getLoc(), diagnostic, PointeeType, PointerType)
.highlight(anchor->getSourceRange());
return true;
}
bool NonOptionalUnwrapFailure::diagnoseAsError() {
auto *anchor = getAnchor();