Fix MethodAmbiguityException for methods with varargs#4725
Merged
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #4725 +/- ##
===============================================
- Coverage 58.287% 58.280% -0.008%
Complexity 2511 2511
===============================================
Files 671 671
Lines 38768 38773 +5
Branches 7034 7036 +2
===============================================
Hits 22597 22597
- Misses 13278 13283 +5
Partials 2893 2893
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
Collaborator
Author
|
I don't understand why the codecov check is failing. I've confirmed that commenting out the lines it claims aren't covered causes the tests to fail, so I guess it's a bug |
Collaborator
|
Thank you for this contribution. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4723
Should fix #4710
It turns out both of these issues did share a root cause after all. The issue is that the specific case of 2 methods with varargs wasn't handled by any of the existing checks for different reasons:
methodBhas varargs whilemethodAdoes not, in which casemethodAis more specific.parameterTypeBis assignable byparameterTypeAand vice-versa which can be used to determine which method is more specific, but this doesn't apply for varags since the vararg is an array type. For example,Stringis assignable toObject, but not toObject...since the latter is an array and a String is not an array.To fix this I added an explicit check for this. If
parameterTypeBis variadic andparameterTypeAis not, thenmethodAmust have the more specific signature (since both methods must be applicable to get this far into the logic).