Bug 544793 - [1.8][compiler] Eclipse compiler shows error on javac-valid construct: Type mismatch
Summary: [1.8][compiler] Eclipse compiler shows error on javac-valid construct: Type m...
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.9   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks: 564617
  Show dependency tree
 
Reported: 2019-02-25 14:09 EST by Zorzella Mising name CLA
Modified: 2022-07-19 10:25 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Zorzella Mising name CLA 2019-02-25 14:09:57 EST
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;
  }
}
Comment 1 Stephan Herrmann CLA 2019-04-02 11:46:54 EDT
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.
Comment 2 Eclipse Genie CLA 2022-07-19 10:25:29 EDT
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.