mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[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:
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user