-
-
Notifications
You must be signed in to change notification settings - Fork 655
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
extern + inline + @:overload: method not inlined #3846
Comments
I just tested and can confirm it works properly on |
@waneck: Are the overloaded fields supposed to have a |
Actually we run |
@Simn, overloads on all platforms but C# and Java cannot have any body, and their |
I know that's what comes out of the syntax, my question is if it should be like this after type loading. How is this supposed to work alongside inlining? Should we really inline the original expression using the overloaded arguments? I don't think that makes any sense in the general case... |
After talking with Caue we agree that this behavior is silly, but I'll work on restoring it for 3.2 somehow to avoid "regressions". In the long run we should disallow inline on fields that have |
This is now "supported". Leaving the issue open because we should talk about this crime against type systems after 3.2. |
I missed this one for the breaking-haxe4 run, but I still think we should break this. Having this kind of overload declaration on an inline function is simply nonsensical, so I consider this a bug. |
This breaks HL because of this thing in Reflect.hx: @:overload(function(f:Array<Dynamic>->Void):Dynamic {})
extern public inline static function makeVarArgs(f:Array<Dynamic>->Dynamic):Dynamic {
return _makeVarArgs(f);
} @ncannasse Could this be implemented differently so we don't have to allow inline + |
Sadly I'm not sure how to avoid this : we need the overload to match Reflect definition and I think we need the inline so it does not cause issue with HL strictly typed system. |
Surely this can just be rewritten to a different expression in the generator... |
See linked commit. Note that I didn't change |
@ncannasse please review |
If CI passes it's ok for me. |
Consider the following code :
On latest haxe/development, it will generate this js code:
As you can see the second call, which correspond to the overloaded signature, won't be inlined.
I use this trick a lot to workaround JS using invalid identifiers in Haxe.
It seems it used to work with previous versions (3.1.3), so it's likely a regression.
As a side note, it might be interresting to allow function bodies in
@:overload
in this situation:It would allow to "translate" different signatures into different calls, including cases where the number of arguments matter.
Of course in JS we can always use
apply/arguments
to forward calls, but it's not ideal.The text was updated successfully, but these errors were encountered: