NullAway
NullAway copied to clipboard
getFunctionalInterfaceMethod() doesn't check super-interfaces
On the latest master (5177099f7d75182ca0f41d466ef8478f7596cb9e). Here's a patch to produce a failing test:
diff --git a/nullaway/src/test/java/com/uber/nullaway/NullAwayTest.java b/nullaway/src/test/java/com/uber/nullaway/NullAwayTest.java
index 43419a6..e318ff0 100644
--- a/nullaway/src/test/java/com/uber/nullaway/NullAwayTest.java
+++ b/nullaway/src/test/java/com/uber/nullaway/NullAwayTest.java
@@ -134,4 +134,9 @@ public class NullAwayTest {
public void rxSupportNegativeCases() {
compilationHelper.addSourceFile("NullAwayRxSupportNegativeCases.java").doTest();
}
+
+ @Test
+ public void functionalMethodSuperInterface() {
+ compilationHelper.addSourceFile("NullAwaySuperFunctionalInterface.java").doTest();
+ }
}
diff --git a/nullaway/src/test/resources/com/uber/nullaway/testdata/NullAwaySuperFunctionalInterface.java b/nullaway/src/test/resources/com/uber/nullaway/testdata/NullAwaySuperFunctionalInterface.java
index e69de29..5d69c07 100644
--- a/nullaway/src/test/resources/com/uber/nullaway/testdata/NullAwaySuperFunctionalInterface.java
+++ b/nullaway/src/test/resources/com/uber/nullaway/testdata/NullAwaySuperFunctionalInterface.java
@@ -0,0 +1,20 @@
+package com.uber.nullaway.testdata;
+
+public class NullAwaySuperFunctionalInterface {
+
+ public void foo() {
+ go(() -> {});
+ }
+
+ private void go(Foo foo) {
+ foo.call();
+ }
+
+ @FunctionalInterface
+ private static interface Foo extends Bar {}
+
+ @FunctionalInterface
+ private static interface Bar {
+ void call();
+ }
+}
Here's the relevant portion of the error stacktrace:
java.lang.AssertionError: An unhandled exception was thrown by the Error Prone static analysis plugin.
Please report this at https://github.com/google/error-prone/issues/new and include the following:
error-prone version: 2.1.1
Stack Trace:
java.lang.RuntimeException: could not find functional interface method in
at com.uber.nullaway.NullabilityUtil.getFunctionalInterfaceMethod(NullabilityUtil.java:87)
at com.uber.nullaway.NullAway.matchLambdaExpression(NullAway.java:422)
...
Nice catch! Working on merging a fix into master now. Thanks!
@mintern would it be helpful to you if we cut a new release with this fix?
It would, thank you. This is currently preventing us from using NullAway due to our reliance on net.mintern.functions.
Thank you for the quick fix!
Thanks for the report! Version 0.1.3 has been released.