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

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

hello @tjoneslow,

thanks for reporting this issue and sorry for the late reaction. I think this is the same issue as reported here CallToDeprecatedMethod issues with generic constructor args . I created ticket to fix it https://jira.sonarsource.com/browse/SONARJAVA-3120