*bug fix* wrong overload invocation of overloaded functions#247
*bug fix* wrong overload invocation of overloaded functions#247Roee-BY wants to merge 3 commits intofrida:mainfrom
Conversation
|
Thanks! As much as I'd like to merge this, this is unfortunately a breaking change and cannot be merged until a future major bump. (There are no doubt existing scripts that rely on the first matching overload being picked.) I think most errors like this stem from this anti-pattern: SomeClass.someMethod.implementation = function (a, b, c) {
return this.someMethod(a, b, c);
};Which really should have been written something like this instead: const someMethod = SomeClass.someMethod.overload('int', 'int', 'int');
someMethod.implementation = function (a, b, c) {
return someMethod.call(this, a, b, c);
};(Or looping over the |
the function invocation mechanism was choosing the first compatible func according the the args and available overloads but there was a bug since some types that are available in java are unified into one type in JS for example JS number can be int double float or long hence choosing the first might cause a problem (in my case an android app crashes due to the incorrect overload). instead of the current mechanism i have implemented a mechanism that goes over all of the overloads and if there is more then one matching overload it invokes the method throwIfDispatcherAmbiguous(dispatcher) which will alert the user about the multiple a available overloads and ask his to choose which one to use.
|
Just took a stab at landing this, and realized that it breaks the test-suite. Looking at the failures, it's clear that this will break a lot of scripts out there. So I'm not sure this is a good idea, even for a major bump. Let's revisit this at a later point in case any new ideas come into mind. |
|
Has this bug been resolved? I believe the bug persists as the application crashes in my case due to the invocation of the incorrect overloaded function. Kindly inform me if it has been addressed or if you have any suggestions for a resolution. I am willing to make modifications to my local system to ensure it functions properly. The progress of my project (research work) is currently on hold due to this issue. |
|
Hi, I'm glad to see someone else is trying to tackle this issue. |
the function invocation mechanism was choosing the first compatible func according the the args and available overloads but there was a bug since some types that are available in java are unified into one type in JS for example JS number can be int double float or long hence choosing the first might cause a problem (in my case an android app crashes due to the incorrect overload). instead of the current mechanism i have implemented a mechanism that goes over all of the overloads and if there is more then one matching overload it invokes the method throwIfDispatcherAmbiguous(dispatcher) which will alert the user about the multiple a available overloads and ask his to choose which one to use.