-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Use lambda parameter counts and block bodies for improved resolution #4757
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
base: master
Are you sure you want to change the base?
Use lambda parameter counts and block bodies for improved resolution #4757
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #4757 +/- ##
===============================================
- Coverage 58.326% 58.296% -0.030%
- Complexity 2514 2516 +2
===============================================
Files 671 671
Lines 38782 38824 +42
Branches 7041 7053 +12
===============================================
+ Hits 22620 22633 +13
- Misses 13271 13300 +29
Partials 2891 2891
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:
|
7b848a1
to
bfc9760
Compare
I don't understand why the codecov/patch check is failing. The tests are covered, so the logic it's complaining about must be too, otherwise the tests don't pass |
This PR might introduce a new crash. I've changed it to a draft while I look into this, so this shouldn't be merged until I've either fixed the new crash or it turns out to be something else. |
1885685
to
9c281d0
Compare
9c281d0
to
82a6f16
Compare
I've found the source of the new crash and added the |
82a6f16
to
67cd6ea
Compare
67cd6ea
to
8b35eb5
Compare
This PR improves lambda-related method resolution by using the lambda parameter count and body for disambiguation in two cases described below. I implemented this by adding the required information to the
LambdaArgumentTypePlaceholder
class, but made sure that, if this information is not provided (such as forMethodReferenceExpr
, type resolution behaviour will be the same as before this PR.Different parameter counts
Consumer.accept
has one parameter whileRunnable.run
has zero, so since the lambda has one parameter, we know this must resolve tofoo(Consumer<String>)
Disambiguation by return type
In this example, the body of the lambda is a block statement which does not contain any return statements. This means that the lambda can only define a method with a
void
return type, so it must defineConsumer<String>
(the same would be true forfoo(input -> { return; })
.If it were
foo(input -> { return ""; })
instead, then the reverse logic would apply. Since the return type of the lambda is notvoid
, it cannot defineConsumer
and must therefore defineFunction
.