Community
Participate
Working Groups
The Snippet below is a stripped-down version of a piece of code I came across that javac compiles, but Eclipse shows a type mismatch error, in this case: Type mismatch: cannot convert from Snippet.Outer<Object> to Snippet.Outer<Snippet.Inner<T>> *************************** package typebug; import java.io.Serializable; import java.util.AbstractCollection; import java.util.List; import java.util.Optional; import java.util.RandomAccess; import java.util.concurrent.Executor; import java.util.concurrent.Future; import java.util.function.Function; import java.util.stream.Collector; import java.util.stream.Stream; public class Snippet { public static <T> void callTransform( Outer<? extends Optional<? extends T>> outerInput) { Outer<Inner<T>> foo = transform(outerInput, input -> stream(input).collect(toInner())); } public interface Outer<V> {} public interface Inner<E> {} public static <E> Collector<E, ?, Inner<E>> toInner() { return null; } public static <T> Stream<T> stream(Optional<T> optional) { return null; } public static <I, O> Outer<O> transform( Outer<I> input, Function<? super I, ? extends O> function) { return null; } }
Thanks for the example. I see it being rejected since the fix for bug 499725 (4.6.2 / 4.7M3). I have put active development regarding type inference involving wildcards on hold, because JLS seems to have some deficiencies in this area. We've been working around some of these in many fixes, worked from private hints from a javac developer, but as witnessed by this current bug, this is not converging to any solution.
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie.