-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
[swift interop] Cannot call instance methods with at least one parameter when using SwiftSelf<T>
#107946
Comments
Tagging subscribers to 'os-ios': @vitek-karas, @kotlarmilos, @ivanpovazan, @steveisok, @akoeplinger |
Tagging subscribers to 'os-tvos': @vitek-karas, @kotlarmilos, @ivanpovazan, @steveisok, @akoeplinger |
Tagging subscribers to this area: @dotnet/interop-contrib |
My impression (from playing around on Godbolt, IIRC) was that the Swift compiler always put this first. Does it actually always put it last? Do you know what the rules are for how the lowering of the self arg is placed? |
I am unable to find any piece of Apple documentation which describes this. Playing around in Godbolt: https://godbolt.org/z/1qj8vsf1h it seems that for both frozen and non-frozen structs it is passed as last argument. Do you remember any example where it was passed as first argument? |
I don't. Looks like we should just switch the requirement to be the last argument then. |
It was might have been the case in Swift 2.2 when |
Our current interop implementation only allows SwiftSelf (representing the self parameter in Swift instance methods) to be specified as the first parameter in function signatures. This design choice leads to issues when interfacing with Swift instance methods that accept additional parameters.
Let's consider following example
addWithExtraArgs
results in the following LLVM-IR:SampleStruct
is expected to be lowered into twoi64
which are passed as last parameters.This would correspond to following csharp signature:
We should either allow
SwiftSelf<T>
argument to be specified as the last parameter or we should reorder the parameters in runtime.\cc: @kotlarmilos, @jakobbotsch, @amanasifkhalid, @matouskozak
The text was updated successfully, but these errors were encountered: