continue inference after raw type detected; report raw after all args were processed with raw result only (IDEA-92273)

This commit is contained in:
Anna Kozlova
2012-10-13 15:31:50 +02:00
parent c50b22e99d
commit 23120f5c8a
3 changed files with 30 additions and 1 deletions
@@ -0,0 +1,23 @@
import java.util.*;
class Test {
List<String> getList(Function<Object, String> function) {
/*
* When the first argument below is a raw type it turns red because IDEA thinks the return
* type is Collection<>. javac and Eclipse don't care
*/
return transform(new ArrayList(), new ArrayList<String>(), function);
}
<R, S, T extends Collection<S>> T transform(Iterable<? extends R> oldCollection, T newCollection, Function<R, S> function) {
for (R r : oldCollection) {
newCollection.add(function.apply(r));
}
return newCollection;
}
interface Function<X, Y> {
Y apply(X input);
}
}