Fix false positives in java/unused parameter

Methods that are mentioned in a member reference expression should count
as rootdefs for the unused parameter query. Such methods have to match
the functional interface of the reference expression, so it is to be
expected that they will sometimes have to declare parameters that they
don't actually use.
This commit is contained in:
Henning Makholm
2019-02-07 21:12:17 +01:00
parent 87c5872bc5
commit b8a03464bf
2 changed files with 15 additions and 0 deletions

View File

@@ -292,6 +292,10 @@ class RootdefCallable extends Callable {
// a body that also doesn't.
not hasUsefulBody(this) and
not exists(Method m | hasUsefulBody(m) | m.overridesOrInstantiates+(this))
or
// Methods that are the target of a member reference need to implement
// the exact signature of the resulting functional interface.
exists(MemberRefExpr mre | mre.getReferencedCallable() = this)
}
}