-
Notifications
You must be signed in to change notification settings - Fork 124
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
Use type specifiers from signature for function ref resolution, if present. Raise exception if resolution is ambiguous. #1410
Conversation
Formatting check succeeded! |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1410 +/- ##
============================================
+ Coverage 63.73% 64.20% +0.47%
+ Complexity 2666 1867 -799
============================================
Files 494 494
Lines 27829 27848 +19
Branches 5528 5531 +3
============================================
+ Hits 17737 17880 +143
+ Misses 7848 7731 -117
+ Partials 2244 2237 -7 ☔ View full report in Codecov by Sentry. |
Hi @JPercival thanks for the tick! I've pushed some changes to the JaCoCo task so that the coverage of |
Scratch that, it's just updated the comment. |
Closes #1408.
The linked issue is due to the engine not being able to distinguish between two
func(List<A>)
andfunc(List<B>)
overloads at runtime. At compile time, the functions are resolved correctly, and it's possible to include the disambiguated signatures in the ELM by setting signature level to Overloads or All. If the signatures are present in the ELM, we should therefore use those signatures to resolve function refs at runtime which will fix the issue.This PR adds support for resolving function refs at runtime using the function ref's signature if the signature is included in the ELM. The changed
FunctionRefEvaluator
now also throws if it cannot disambiguate between multiple candidate function defs.Below is an overview of the
FunctionRefEvaluator
logic before and after the change.BEFORE: Find the function defs with the matching name and number of operands. If only one function def is found, pick that function def and stop there. If there are multiple candidate function defs, pick the first one with the matching operand types. The Java class types of the function ref's signature (if present, type specifiers are converted to Java classes) or of the evaluated argument expressions are used for comparison. If no function defs are matched in the end, an exception is thrown
Could not resolve call to operator 'FUNCTION(ARGUMENT_TYPES)' in library 'LIBRARY_NAME'.
.AFTER: Find the function defs with the matching name. If the function ref includes a signature, use the signature to further select the matching function defs (type specifiers are used for comparison). If the function ref doesn't include a signature, the Java class types of the evaluated argument expressions are used for comparison. If no function defs are left in the end, an exception is thrown
Could not resolve call to operator 'FUNCTION(ARGUMENT_TYPES)' in library 'LIBRARY_NAME'.
. If there are multiple matching function defs, an exception is thrownAmbiguous call to operator 'FUNCTION(ARGUMENT_TYPES)' in library 'LIBRARY_NAME'.
. If only one function def is left in the end, pick that function def (normal case).I am reusing the type specifier comparison implementation from the
SimpleElmEvaluator
class, which was handy.