Skip to content

Commit a65481e

Browse files
wip eclipse 4.7
1 parent 117e8c5 commit a65481e

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed

src/main/java/packageNotAnnotated/IntelliJNullabilityTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public static void test() {
1919
MyNonNullGenericClass<@NonNull String> toto = new MyNonNullGenericClass<>();
2020
System.out.println(toto);
2121

22-
// IntelliJ bug : should complain
22+
// should complain
2323
MyNonNullGenericClass<@Nullable String> titi = new MyNonNullGenericClass<>();
2424
System.out.println(titi);
2525

src/main/java/test/EverythingNonNullByDefault.java

+2-4
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,7 @@ public static <T> T typeArgument(List<T> l) {
6969
@NonNullByDefault({ PARAMETER, RETURN_TYPE, FIELD, TYPE_BOUND, TYPE_ARGUMENT, TYPE_PARAMETER })
7070
public static <T> T typeArgumentNonNull(List<T> l) {
7171
l.add(null);
72-
// #Eclipse 4.6.3 bug?# we should have no error because
73-
// @NonNullByDefault with TYPE_PARAMETER should treat T as @Nonnull and
74-
// therefore l.get(0) too
72+
7573
l.get(0).toString();
7674
return l.get(0);
7775
}
@@ -118,7 +116,7 @@ public static void apply() {
118116
if (o.city != null) {
119117
o.setName("foo");
120118
// now "syntactic null analysis for fields" is not applied because
121-
// there was a satement between the test for nullability of the
119+
// there was a statement between the test for nullability of the
122120
// field and its usage. Eclipse has no means to know that setName()
123121
// did not modify the city field
124122
o.city.toString();

src/main/java/test/UseSpringWithExternalAnnotations.java

+18
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
package test;
22

3+
import static org.eclipse.jdt.annotation.DefaultLocation.TYPE_PARAMETER;
4+
35
import java.util.Collection;
6+
import java.util.List;
47

8+
import org.eclipse.jdt.annotation.NonNullByDefault;
59
import org.springframework.util.CollectionUtils;
610

711
public class UseSpringWithExternalAnnotations {
@@ -10,4 +14,18 @@ public void useSpring() {
1014
Collection<String> strs = null;
1115
CollectionUtils.isEmpty(strs);
1216
}
17+
18+
@NonNullByDefault({ TYPE_PARAMETER })
19+
public static <T> void typeArgumentNonNull(List<T> l) {
20+
l.get(0);
21+
l.get(0).toString();
22+
}
23+
24+
class X {
25+
@NonNullByDefault(TYPE_PARAMETER)
26+
<T> T identity(T t) {
27+
return null;
28+
}
29+
}
30+
1331
}

0 commit comments

Comments
 (0)