Bug 534694

Summary: [1.8][inference] Eclipse compiler behaves differently from javac
Product: [Eclipse Project] JDT Reporter: Philemon Schucker <phili0815>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: NEW --- QA Contact:
Severity: normal    
Priority: P3 CC: stephan.herrmann
Version: 4.7.3   
Target Milestone: ---   
Hardware: PC   
OS: Windows 10   
Whiteboard: stalebug
Bug Depends on:    
Bug Blocks: 564617    
Attachments:
Description Flags
Examples none

Description Philemon Schucker CLA 2018-05-15 09:23:02 EDT
Created attachment 274045 [details]
Examples

Found a strange behaviour where the eclipse compiler fails to compile a file, that compiles without any problems with Oracle JDK's javac. Seems to be a problem with type inference and bounded generics.

Playing around with the position of the type parameters, I was able to make eclipse compile the file. But now javac fails!

I added a minimalized example showing the problem (maybe it could be minimized more).

Example 1 compiles in Eclipse but not with javac. (Error: incompatible types: cannot infer type-variable(s) T; this.action(a.get().entrySet(), this::handleEntry);)

Example 2 compiles with javac but not with Eclipse.  (Error: The type Test does not define handleEntry(List<Test.A>, Map.Entry<String,List<capture#1-of ? extends Test.A>>) that is applicable here)

Note that the only difference between these two examples is the handleEntry function's signature.

Tested with Java 8 and 10 in Eclipse Oxygen 4.7.3a.
Comment 1 Stephan Herrmann CLA 2018-05-15 12:56:00 EDT
Thanks for the examples.

Figuring out, which compiler is right or wrong in this kind of situations can be quite a hard nut to crack. So please don't hold your breath waiting for a change.

From a quick glance it seems that ecj is able to unify the type variable T with a wildcard, but it cannot unify two distinct wildcards. At this level I can find no fault at ecj's behavior, but please take this statement with a grain of salt.
Comment 2 Eclipse Genie CLA 2022-07-25 12:53:43 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.