[SIL] Fixed return index for call-as-async (BOOL, Error, Value) case. #38825
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When converting an ObjC method type which is being called as async to a Swift function type, some of the values passed to the ObjC method's completion handler are converted to return values of the Swift function. The flag and error parameters, however, if present, are ignored.
When abstracting the result type for the Swift method, the formal type of the corresponding parameter in the ObjC method's completion handler is used. Digging out that parameter entails indexing into the parameters of the completion handler. Previously, the indexing logic relied on the error appearing before the flag if both appeared before the value of interest. Here, the indexing is tweaked to check both special indices for each possible index until the first that matches neither is found.
Based on #38785 .
rdar://81625544