Deprecation detection doesn't correctly infer types for overloaded method references

java
sonarqube

(Thomas Jones-Low) #1

The error from SonarQube(“MINOR Remove this use of “whileTrue”; it is deprecated.“) ( squid:CallToDeprecatedMethod ) concerns lines like:

nextFuture = AsyncUtil.whileTrue(this::nextStep, getExecutor()).thenApply(vignore -> {

AsyncUtil.whileTrue() is overloaded: it has a (deprecated) overload that takes a Function<Void,? extends CompletableFuture and another overload that takes a Supplier<CompletableFuture>. The signature for nextStep() is: CompletableFuture nextStep().

The Java compiler and IntelliJ both correct infer that the type for the method reference is Supplier<CompletableFuture>, but SonarQube doesn’t realize this.

We’re using SonarQube Version 6.7.1 (build 35068), sonarqube-gradle-plugin version 2.6, and Gradle 4.6