Environment
Eclipse IDE 2020-06 (4.16.0), build id 20200615-1200
SonarLint for Eclipse 5.2.1.18852
Windows 10 Pro 1903 build 18362.900
Problem
double compute() {
long sum = List.of(1, 2, 3).stream().mapToLong(i -> {
return i * i;
}).sum();
return sum;
}
SonarLint falsely warns in the lambda statement on the *
(java:S2184) Cast one of the operands of this multiplication operation to a “double”.
although the target type of the lambda is long
and only the return type of the outer method is double
. This bug may be related to this Eclipse bug because the return i * i;
is falsely marked as exit point of the compute()
method.