| Summary: | [compiler] Eclipse compiles codes which javac rejects: incompatible types | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Robert Munteanu <robert.munteanu> |
| Component: | Core | Assignee: | Stephan Herrmann <stephan.herrmann> |
| Status: | VERIFIED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | manoj.palat, mathias.arens, michael.f.obrien, stephan.herrmann |
| Version: | 3.6.1 | ||
| Target Milestone: | 4.9 M2 | ||
| Hardware: | PC | ||
| OS: | All | ||
| See Also: |
https://git.eclipse.org/r/125279 https://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?id=527238d845cdbbd9ba43a82cb6c0f2d5186c00e8 |
||
| Whiteboard: | |||
Srikanth, please investigate. Thanks! Is there any chance for this will be considered for 3.7 ? The getOnlyElement method signature is copied from the guava ( formerly google collections) class Iterables, which I assume is in relatively widespread use. Not to mention that it's quite unpleasant to debug why your CI build fails when Eclipse compiles just fine. I'll see what I can do here -- Thanks. There is a similar issue reported in bug 340506 New Gerrit change created: https://git.eclipse.org/r/125279 Gerrit change https://git.eclipse.org/r/125279 was merged to [master]. Commit: http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?id=527238d845cdbbd9ba43a82cb6c0f2d5186c00e8 (In reply to Eclipse Genie from comment #6) > Gerrit change https://git.eclipse.org/r/125279 was merged to [master]. > Commit: > http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/ > ?id=527238d845cdbbd9ba43a82cb6c0f2d5186c00e8 I added a test that demonstrates correct error reporting at 1.8+ Since type inference in 1.7- is a completely different story, I am not planning to 'downport' this behavior, given this bug has been quiet for some years. Verified with Eclipse 4.9 m2 Build id: I20180731-0800 |
The following class compiles in Eclipse: bc. public class Example { public static void doSomething() { DoJobMr bean = getOnlyElement(new ArrayList()); } public static <T> T getOnlyElement(Iterable<T> iterable) { return null; } public static class DoJobMr { } } but it not compiled by javac 1.6.0_22 bc. src/Example.java:12: incompatible types found : java.lang.Object required: Example.DoJobMr DoJobMr bean = getOnlyElement(new ArrayList()); ^