Skip to content

Commit 5186c11

Browse files
committed
Even more new javac warnings
1 parent 2f04d02 commit 5186c11

15 files changed

Lines changed: 42 additions & 37 deletions

src/main/java/com/jnape/palatable/lambda/iteration/MappingIterable.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@
99
import static java.util.Collections.singletonList;
1010

1111
public final class MappingIterable<A, B> implements Iterable<B> {
12-
private final Iterable as;
13-
private final List<Function> mappers;
12+
private final Iterable<A> as;
13+
private final List<Function<?, ?>> mappers;
1414

1515
@SuppressWarnings("unchecked")
1616
public MappingIterable(Function<? super A, ? extends B> fn, Iterable<A> as) {
17-
List<Function> mappers = new ArrayList<>(singletonList(fn));
18-
while (as instanceof MappingIterable) {
17+
List<Function<?, ?>> mappers = new ArrayList<>(singletonList(fn));
18+
while (as instanceof MappingIterable<?, ?>) {
1919
MappingIterable<?, ?> nested = (MappingIterable<?, ?>) as;
20-
as = (Iterable) nested.as;
20+
as = (Iterable<A>) nested.as;
2121
mappers.addAll(0, nested.mappers);
2222
}
2323
this.as = as;
@@ -27,7 +27,8 @@ public MappingIterable(Function<? super A, ? extends B> fn, Iterable<A> as) {
2727
@Override
2828
@SuppressWarnings("unchecked")
2929
public Iterator<B> iterator() {
30-
Function fnComposedOnTheHeap = o -> foldLeft((x, fn) -> fn.apply(x), o, mappers);
31-
return new MappingIterator<>(fnComposedOnTheHeap, as.iterator());
30+
Function<Object, Object> fnComposedOnTheHeap = a -> foldLeft((x, fn) -> ((Function<Object, Object>) fn).apply(x),
31+
a, mappers);
32+
return new MappingIterator<>((Function<? super A, ? extends B>) fnComposedOnTheHeap, as.iterator());
3233
}
3334
}

src/main/java/com/jnape/palatable/lambda/iteration/UnfoldingIterator.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ public boolean hasNext() {
2727
}
2828

2929
@Override
30-
@SuppressWarnings("ConstantConditions")
3130
public A next() {
3231
if (!hasNext())
3332
throw new NoSuchElementException();

src/test/java/com/jnape/palatable/lambda/functor/BifunctorTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class BifunctorTest {
1414

1515
@Test
1616
public void biMapLUsesIdentityForRightBiMapFunction() {
17-
AtomicReference<Function> rightInvocation = new AtomicReference<>();
17+
AtomicReference<Function<?, ?>> rightInvocation = new AtomicReference<>();
1818
Bifunctor<String, Integer, InvocationRecordingBifunctor<?, ?>> bifunctor =
1919
new InvocationRecordingBifunctor<>(new AtomicReference<>(), rightInvocation);
2020
bifunctor.biMapL(String::toUpperCase);
@@ -23,7 +23,7 @@ public void biMapLUsesIdentityForRightBiMapFunction() {
2323

2424
@Test
2525
public void biMapRUsesIdentityForLeftBiMapFunction() {
26-
AtomicReference<Function> leftInvocation = new AtomicReference<>();
26+
AtomicReference<Function<?, ?>> leftInvocation = new AtomicReference<>();
2727
Bifunctor<String, Integer, InvocationRecordingBifunctor<?, ?>> bifunctor =
2828
new InvocationRecordingBifunctor<>(leftInvocation, new AtomicReference<>());
2929
bifunctor.biMapR(String::valueOf);

src/test/java/com/jnape/palatable/lambda/functor/ProfunctorTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class ProfunctorTest {
1414

1515
@Test
1616
public void diMapLUsesIdentityForRightDiMapFunction() {
17-
AtomicReference<Function> rightInvocation = new AtomicReference<>();
17+
AtomicReference<Function<?, ?>> rightInvocation = new AtomicReference<>();
1818
Profunctor<String, Integer, InvocationRecordingProfunctor<?, ?>> profunctor =
1919
new InvocationRecordingProfunctor<>(new AtomicReference<>(), rightInvocation);
2020
profunctor.diMapL(Object::toString);
@@ -23,7 +23,7 @@ public void diMapLUsesIdentityForRightDiMapFunction() {
2323

2424
@Test
2525
public void diMapRUsesIdentityForLeftDiMapFunction() {
26-
AtomicReference<Function> leftInvocation = new AtomicReference<>();
26+
AtomicReference<Function<?, ?>> leftInvocation = new AtomicReference<>();
2727
Profunctor<String, Integer, InvocationRecordingProfunctor<?, ?>> profunctor =
2828
new InvocationRecordingProfunctor<>(leftInvocation, new AtomicReference<>());
2929
profunctor.diMapR(String::valueOf);

src/test/java/com/jnape/palatable/lambda/iteration/DroppingIteratorTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public class DroppingIteratorTest {
1717

1818
@Mock private Iterator<Object> iterator;
1919

20-
private DroppingIterator droppingIterator;
20+
private DroppingIterator<?> droppingIterator;
2121

2222
@Before
2323
public void setUp() {

src/test/java/com/jnape/palatable/lambda/iteration/ImmutableIteratorTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77

88
public class ImmutableIteratorTest {
99

10-
private ImmutableIterator immutableIterator;
10+
private ImmutableIterator<?> immutableIterator;
1111

1212
@Before
1313
public void setUp() {
14-
immutableIterator = new ImmutableIterator() {
14+
immutableIterator = new ImmutableIterator<Object>() {
1515
@Override
1616
public boolean hasNext() {
1717
throw outOfScope();

src/test/java/com/jnape/palatable/lambda/iteration/InfiniteIteratorTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99

1010
public class InfiniteIteratorTest {
1111

12-
private InfiniteIterator infiniteIterator;
12+
private InfiniteIterator<?> infiniteIterator;
1313

1414
@Before
1515
public void setUp() {
16-
infiniteIterator = new InfiniteIterator() {
16+
infiniteIterator = new InfiniteIterator<Object>() {
1717
@Override
1818
public Object next() {
1919
throw outOfScope();

src/test/java/com/jnape/palatable/lambda/iteration/ReversingIteratorTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public class ReversingIteratorTest {
2222

2323
@Mock private Iterator<Object> iterator;
2424

25-
private ReversingIterator reversingIterator;
25+
private ReversingIterator<?> reversingIterator;
2626

2727
@Before
2828
public void setUp() {
@@ -47,6 +47,7 @@ public void reversesIterator() {
4747
}
4848

4949
@Test
50+
@SuppressWarnings("ResultOfMethodCallIgnored")
5051
public void doesNotReverseUntilNextIsCalled() {
5152
reversingIterator.hasNext();
5253
verify(iterator, never()).next();
@@ -63,6 +64,7 @@ public void doesNotHaveNextIfFinishedReversingIterator() {
6364
}
6465

6566
@Test
67+
@SuppressWarnings("ResultOfMethodCallIgnored")
6668
public void neverInteractsWithIteratorAgainAfterInitialReverse() {
6769
mockIteratorToHaveValues(iterator, 1, 2, 3);
6870

src/test/java/com/jnape/palatable/lambda/iteration/RewindableIteratorTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class RewindableIteratorTest {
1818

1919
@Mock private Iterator<Object> iterator;
2020

21-
private RewindableIterator rewindableIterator;
21+
private RewindableIterator<?> rewindableIterator;
2222

2323
@Before
2424
public void setUp() {

src/test/java/testsupport/Mocking.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ public static <A> Iterable<A> mockIterable() {
1818
}
1919

2020
@SafeVarargs
21-
public static <T> void mockIteratorToHaveValues(Iterator iterator, T... values) {
22-
Iterator real = asList(values).iterator();
21+
@SuppressWarnings("varargs")
22+
public static <T> void mockIteratorToHaveValues(Iterator<?> iterator, T... values) {
23+
Iterator<?> real = asList(values).iterator();
2324

2425
when(iterator.hasNext()).then(delegateTo(real));
2526
when(iterator.next()).then(delegateTo(real));

0 commit comments

Comments
 (0)