IDEA-143937 Bogus warning by 'Constant conditions & exceptions' inspection within lambda expressions, due to JSR 305 @TypeQualifierDefault annotation

This commit is contained in:
peter
2015-08-18 20:00:23 +02:00
parent ab3bd68ec0
commit 0bae70149a
4 changed files with 55 additions and 0 deletions
@@ -0,0 +1,26 @@
import javax.annotation.*;
@ParametersAreNonnullByDefault
class Test {
void foo() {
Intf i1 = (o) -> {
if (o == null) {
System.out.println();
}
};
Intf i2 = (Object o) -> {
if (<warning descr="Condition 'o == null' is always 'false'">o == null</warning>) {
System.out.println();
}
};
Intf i3 = (@Nullable Object o) -> {
if (o == null) {
System.out.println();
}
};
}
}
interface Intf {
void foo(Object o);
}
@@ -14,6 +14,17 @@ class Some {
}
@javax.annotation.ParametersAreNonnullByDefault
class CheckLoop {
void foo(Iterable<String> it) {
for (String s : it) {
if (s == null) { // it's not ElementType.PARAMETER, no warning here
System.out.println();
}
}
}
}
@javax.annotation.ParametersAreNonnullByDefault
class NotNullClass {
static void foo(String s) {}