Merge pull request #787 from hmakholm/pr/fix-useless-parameter

Fix false positives in java/unused parameter
This commit is contained in:
Anders Schack-Mulligen
2019-02-11 11:49:21 +01:00
committed by GitHub
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)
}
}

View File

@@ -40,6 +40,10 @@ abstract class C implements I {
}
}
interface F {
void doSomething(int arg2);
}
public class Test {
// OK: external interface
public static void main(String[] args) {}
@@ -54,6 +58,13 @@ public class Test {
public static void foo(Object bar) {
throw new UnsupportedOperationException();
}
public static F getF() {
return Test::myFImplementation;
}
// OK: mentioned in member reference
private static void myFImplementation(int foo) {}
// OK: native method
native int baz(int x);