Files
openide/java/java-tests/testData/inspection/nullableProblems/ForeachParameterNullability.java
peter 3fb458c651 IDEA-171248 Nullability: missing warning in for-each cycle
support for forEach lambda parameters
2017-06-30 15:44:06 +02:00

23 lines
866 B
Java

import typeUse.*;
import java.util.*;
class JC {
public static Collection<@Nullable Object> getNullableStuff() {
return Collections.emptyList();
}
public static Collection<@NotNull Object> getNotNullStuff() {
return Collections.emptyList();
}
void usage() {
for (<warning descr="Parameter can be null">@NotNull</warning> Object o : getNullableStuff()) {
System.out.println(o.getClass());
}
for (<warning descr="Parameter is always not-null">@Nullable</warning> Object o : getNotNullStuff()) {
System.out.println(o.getClass());
}
getNullableStuff().forEach((<warning descr="Parameter can be null">@NotNull</warning> Object s) -> System.out.println(s.hashCode()));
getNotNullStuff().forEach((<warning descr="Parameter is always not-null">@Nullable</warning> Object s) -> System.out.println(s.hashCode()));
}
}