False positive for infinite recursion check on overloaded methods
- Dominant language
- Java
- Stars
- 7.2k
- Forks
- 820
- Avg merge
- 5h 9m
- Merged PRs (30d)
- 50
Description
The [infinite recursion check](https://errorprone.info/bugpattern/InfiniteRecursion) incorrectly reports infinite recursion in the following code:
```
protected int findDirectoryGraphDistance(SourceFile a, SourceFile b) {
return findDirectoryGraphDistance(a.getPath(), b.getPath());
}
protected int findDirectoryGraphDistance(FilePath a, FilePath b) {
return 1234;
}
```
This is not even recursion, it's just a method calling another overloaded method with the same name but different types.
I'm not sure why this happens, but one of the reasons could be that `SourceFile` is part of our own code base while `FilePath` is a library class. That might influence ErrorProne's ability to resolve parameter types.
Sure, the quick fix would be to either rename one of the methods or to add a `@SuppressWarnings`, but for other users it would be nice if we can avoid this false positive altogether.
Contributor guide
Assessment
This issue has not been assessed yet.