File tree Expand file tree Collapse file tree 6 files changed +20
-24
lines changed
android/guava/src/com/google/common/collect
guava/src/com/google/common/collect Expand file tree Collapse file tree 6 files changed +20
-24
lines changed Original file line number Diff line number Diff line change @@ -785,8 +785,8 @@ public final boolean isEmpty() {
785785 * copied
786786 */
787787 @ GwtIncompatible // Array.newArray(Class, int)
788- public final @ Nullable E [] toArray (Class <@ NonNull E > type ) {
789- return Iterables .toArray (getDelegate (), type );
788+ public final E [] toArray (Class <@ NonNull E > type ) {
789+ return Iterables .< E > toArray (getDelegate (), type );
790790 }
791791
792792 /**
Original file line number Diff line number Diff line change 3636import java .util .RandomAccess ;
3737import java .util .Set ;
3838import javax .annotation .CheckForNull ;
39+ import org .checkerframework .checker .nullness .qual .NonNull ;
3940import org .checkerframework .checker .nullness .qual .Nullable ;
4041
4142/**
@@ -323,12 +324,8 @@ public static String toString(Iterable<?> iterable) {
323324 * @return a newly-allocated array into which all the elements of the iterable have been copied
324325 */
325326 @ GwtIncompatible // Array.newInstance(Class, int)
326- /*
327- * If we could express Class<@Nonnull T>, we could generalize the type parameter to <T extends
328- * @Nullable Object>, and then we could accept an Iterable<? extends T> and return a plain T[]
329- * instead of a @Nullable T[].
330- */
331- public static <T > @ Nullable T [] toArray (Iterable <? extends @ Nullable T > iterable , Class <T > type ) {
327+ public static <T extends @ Nullable Object > T [] toArray (
328+ Iterable <? extends T > iterable , Class <@ NonNull T > type ) {
332329 return toArray (iterable , ObjectArrays .newArray (type , 0 ));
333330 }
334331
Original file line number Diff line number Diff line change 4747import java .util .PriorityQueue ;
4848import java .util .Queue ;
4949import javax .annotation .CheckForNull ;
50+ import org .checkerframework .checker .nullness .qual .NonNull ;
5051import org .checkerframework .checker .nullness .qual .Nullable ;
5152
5253/**
@@ -344,10 +345,10 @@ public static String toString(Iterator<?> iterator) {
344345 * @return a newly-allocated array into which all the elements of the iterator have been copied
345346 */
346347 @ GwtIncompatible // Array.newInstance(Class, int)
347- // For discussion of this signature, see the corresponding overload of *Iterables*. toArray.
348- public static < T > @ Nullable T [] toArray ( Iterator <? extends @ Nullable T > iterator , Class <T > type ) {
349- List <@ Nullable T > list = Lists .newArrayList (iterator );
350- return Iterables .toArray (list , type );
348+ public static < T extends @ Nullable Object > T [] toArray (
349+ Iterator <? extends T > iterator , Class <@ NonNull T > type ) {
350+ List <T > list = Lists .newArrayList (iterator );
351+ return Iterables .< T > toArray (list , type );
351352 }
352353
353354 /**
Original file line number Diff line number Diff line change @@ -777,8 +777,8 @@ public final boolean isEmpty() {
777777 * copied
778778 */
779779 @ GwtIncompatible // Array.newArray(Class, int)
780- public final @ Nullable E [] toArray (Class <@ NonNull E > type ) {
781- return Iterables .toArray (getDelegate (), type );
780+ public final E [] toArray (Class <@ NonNull E > type ) {
781+ return Iterables .< E > toArray (getDelegate (), type );
782782 }
783783
784784 /**
Original file line number Diff line number Diff line change 3939import java .util .function .Consumer ;
4040import java .util .stream .Stream ;
4141import javax .annotation .CheckForNull ;
42+ import org .checkerframework .checker .nullness .qual .NonNull ;
4243import org .checkerframework .checker .nullness .qual .Nullable ;
4344
4445/**
@@ -285,12 +286,8 @@ public static String toString(Iterable<?> iterable) {
285286 * @return a newly-allocated array into which all the elements of the iterable have been copied
286287 */
287288 @ GwtIncompatible // Array.newInstance(Class, int)
288- /*
289- * If we could express Class<@Nonnull T>, we could generalize the type parameter to <T extends
290- * @Nullable Object>, and then we could accept an Iterable<? extends T> and return a plain T[]
291- * instead of a @Nullable T[].
292- */
293- public static <T > @ Nullable T [] toArray (Iterable <? extends @ Nullable T > iterable , Class <T > type ) {
289+ public static <T extends @ Nullable Object > T [] toArray (
290+ Iterable <? extends T > iterable , Class <@ NonNull T > type ) {
294291 return toArray (iterable , ObjectArrays .newArray (type , 0 ));
295292 }
296293
Original file line number Diff line number Diff line change 4747import java .util .PriorityQueue ;
4848import java .util .Queue ;
4949import javax .annotation .CheckForNull ;
50+ import org .checkerframework .checker .nullness .qual .NonNull ;
5051import org .checkerframework .checker .nullness .qual .Nullable ;
5152
5253/**
@@ -344,10 +345,10 @@ public static String toString(Iterator<?> iterator) {
344345 * @return a newly-allocated array into which all the elements of the iterator have been copied
345346 */
346347 @ GwtIncompatible // Array.newInstance(Class, int)
347- // For discussion of this signature, see the corresponding overload of *Iterables*. toArray.
348- public static < T > @ Nullable T [] toArray ( Iterator <? extends @ Nullable T > iterator , Class <T > type ) {
349- List <@ Nullable T > list = Lists .newArrayList (iterator );
350- return Iterables .toArray (list , type );
348+ public static < T extends @ Nullable Object > T [] toArray (
349+ Iterator <? extends T > iterator , Class <@ NonNull T > type ) {
350+ List <T > list = Lists .newArrayList (iterator );
351+ return Iterables .< T > toArray (list , type );
351352 }
352353
353354 /**
You can’t perform that action at this time.
0 commit comments