Closed
Description
Description of the problem / feature request:
UnnecessaryMethodReference
gives a false-positive when variable is super
.
Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
package test;
public class TestErrorProneSuper
{
public static class S
implements Closeable
{
@Override
public void close()
throws IOException
{
System.out.println("Closing S");
}
}
public static class T
extends S
{
Closer closer = Closer.create();
@Override
public void close() throws IOException
{
System.out.println("Closing T");
closer.register(super::close);
}
}
public static void main(String[] args)
{
try {
new T().close();
}
catch (IOException e) {
throw new UncheckedIOException(e);
}
}
}
Gives false-positive:
TestErrorProneSuper.java:[44,29] [UnnecessaryMethodReference] This method reference is unnecessary, and can be replaced with the variable itself.
(see https://errorprone.info/bugpattern/UnnecessaryMethodReference)
Did you mean 'closer.register(super);'?
which is not correct (cannot pass super as a variable: TestErrorProneSuper.java:[44,34] '.' expected
)
What version of Error Prone are you using?
2.5.0
Have you found anything relevant by searching the web?
Nope :)
Metadata
Metadata
Assignees
Labels
No labels
Activity
Fix handling of `super::` method references in `UnnecessaryMethodRefe…
super::
method references inUnnecessaryMethodReference
#2111Fix handling of `super::` method references in `UnnecessaryMethodRefe…
Fix handling of `super::` method references in `UnnecessaryMethodRefe…