-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[SILGen] Fixed handler formal arg type indexing. #38785
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@swift-ci please test |
Build failed |
@swift-ci please clean test linux platform |
Build failed |
0315413
to
5e352f8
Compare
@swift-ci please test |
@swift-ci please clean test windows platform |
Build failed |
5e352f8
to
9e66e33
Compare
@swift-ci please test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks Nate!
Previously, the function emitCBridgedToNativeValue handled three situations around optionals: - Bridged?, Native? - Bridged, Native? - Bridged, Native Here, handling for the fourth case - Bridged?, Native is added. To enable this, the number of Optional wrappings that the bridged type has that the native type does not is passed in to the function. Then, in the portions of the function where actual transformations are done, the values are unwrapped an appropriate number of times. Mostly that means force unwrapping N times before doing the transformation. In the case of types that conform to _ObjectiveCBridgeable, however, it means force unwrapping the value N-1 times after doing the transformation because _ObjectiveCBridgeable._unconditionallyBridgeFromObjectiveC performs one layer of unwrapping itself. rdar://81590807
In the synthesized completion handler that is passed to ObjC methods that are called as async, the formal type of each argument is the corresponding parameter of the formal type of the block. The non-error, non-index arguments need to be prepared so that they can be used to fulfill the continuation; the lambda which does that preparation for each such argument takes the formal type of that argument. As such, the call to that lambda needs to pass the type of the corresponding parameter of the formal type of the block to that lambda. Doing so entails skipping over the error and flag parameters if they appear before some of the non-error, non-index arguments. Previously, no parameters were skipped over. Consequently, when an error or flag argument preceded one of the non-error, non-index arguments, the wrong formal type was passed to the preparation lambda. Here, that is fixed by passing the correct index. The to-be-used indices for the formal block parameters are the same as the to-be-used indices for the lowered block parameters minus one reflecting the fact that the lowered block always has an initial block_storage parameter as the first argument which the formal type never has. rdar://81617749
9e66e33
to
cef64c9
Compare
@swift-ci please test |
Build failed |
@swift-ci please clean test macos platform |
In the synthesized completion handler that is passed to ObjC methods that are called as async, the formal type of each argument is the corresponding parameter of the formal type of the block. The non-error, non-index arguments need to be prepared so that they can be used to fulfill the continuation; the lambda which does that preparation for each such argument takes the formal type of that argument. As such, the call to that lambda needs to pass the type of the corresponding parameter of the formal type of the block to that lambda. Doing so entails skipping over the error and flag parameters if they appear before some of the non-error, non-index arguments.
Previously, no parameters were skipped over. Consequently, when an error or flag argument preceded one of the non-error, non-index arguments, the wrong formal type was passed to the preparation lambda.
Here, that is fixed by passing the correct index. The to-be-used indices for the formal block parameters are the same as the to-be-used indices for the lowered block parameters minus one reflecting the fact that the lowered block always has an initial block_storage parameter as the first argument which the formal type never has.
Based on #38773 .
rdar://81617749