@@ -179,15 +179,18 @@ public void genericInferenceOnAssignments() {
179179 " }" ,
180180 " }" ,
181181 " static void testLocalAssign() {" ,
182- // " // legal",
183- // " Foo<@Nullable Object> f1 = Foo.makeNull(null);",
184- // " // BUG: Diagnostic contains: passing @Nullable parameter 'null' where @NonNull is required",
185- // " Foo<Object> f2 = Foo.makeNull(null);",
186- // " // ILLEGAL: U does not have a @Nullable upper bound",
187- // " // BUG: Diagnostic contains: passing @Nullable parameter 'null' where @NonNull is required",
188- // " Foo<@Nullable Object> f3 = Foo.makeNonNull(null);",
189- // " // BUG: Diagnostic contains: passing @Nullable parameter 'null' where @NonNull is required",
190- // " Foo<Object> f4 = Foo.makeNonNull(null);",
182+ // " // legal",
183+ // " Foo<@Nullable Object> f1 = Foo.makeNull(null);",
184+ // " // BUG: Diagnostic contains: passing @Nullable parameter 'null'
185+ // where @NonNull is required",
186+ // " Foo<Object> f2 = Foo.makeNull(null);",
187+ // " // ILLEGAL: U does not have a @Nullable upper bound",
188+ // " // BUG: Diagnostic contains: passing @Nullable parameter 'null'
189+ // where @NonNull is required",
190+ // " Foo<@Nullable Object> f3 = Foo.makeNonNull(null);",
191+ // " // BUG: Diagnostic contains: passing @Nullable parameter 'null'
192+ // where @NonNull is required",
193+ // " Foo<Object> f4 = Foo.makeNonNull(null);",
191194 " Foo<@Nullable Object> f5 = Foo.makeNonNull(new Object());" ,
192195 " }" ,
193196 " }" )
@@ -247,24 +250,25 @@ public void genericInferenceOnAssignmentsMultipleParams() {
247250 @ Test
248251 public void genericsUsedForGenericClasses () {
249252 makeHelper ()
250- .addSourceLines (
251- "Test.java" ,
252- "package com.uber;" ,
253- "import org.jspecify.annotations.Nullable;" ,
254- "import java.util.ArrayList;" ,
255- "class Test {" ,
256- " abstract class Foo<K, V> {" ,
257- " abstract <U, R> Foo<U,ArrayList<R>> nonNullTest();" ,
258- " abstract <U extends @Nullable Object, R extends @Nullable Object> Foo<U,ArrayList<R>> nullTest();" ,
259- " }" ,
260- " static void test(Foo<Void, Void> f) {" ,
261- " Foo<Integer, ArrayList<String>> fooNonNull_1 = f.nonNullTest();" ,
262- " Foo<Integer, ArrayList<@Nullable String>> fooNonNull_2 = f.nonNullTest();" , // error message
263- " Foo<Integer, ArrayList<String>> fooNull_1 = f.nullTest();" ,
264- " Foo<Integer, ArrayList<@Nullable String>> fooNull_2 = f.nullTest();" , // error message
265- " }" ,
266- "}" )
267- .doTest ();
253+ .addSourceLines (
254+ "Test.java" ,
255+ "package com.uber;" ,
256+ "import org.jspecify.annotations.Nullable;" ,
257+ "import java.util.ArrayList;" ,
258+ "class Test {" ,
259+ " abstract class Foo<K, V> {" ,
260+ " abstract <U, R> Foo<U,ArrayList<R>> nonNullTest();" ,
261+ " abstract <U extends @Nullable Object, R extends @Nullable Object> Foo<U,ArrayList<R>> nullTest();" ,
262+ " }" ,
263+ " static void test(Foo<Void, Void> f) {" ,
264+ " Foo<Integer, ArrayList<String>> fooNonNull_1 = f.nonNullTest();" ,
265+ " Foo<Integer, ArrayList<@Nullable String>> fooNonNull_2 = f.nonNullTest();" , // error message
266+ " Foo<Integer, ArrayList<String>> fooNull_1 = f.nullTest();" ,
267+ " Foo<Integer, ArrayList<@Nullable String>> fooNull_2 = f.nullTest();" , // error
268+ // message
269+ " }" ,
270+ "}" )
271+ .doTest ();
268272 }
269273
270274 @ Test
0 commit comments