Bug 519256 - Unexpected type error
Summary: Unexpected type error
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.8   Edit
Hardware: PC Mac OS X
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords: helpwanted
Depends on:
Blocks:
 
Reported: 2017-07-05 13:52 EDT by Fabian Stäber CLA
Modified: 2022-06-20 09:56 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 Fabian Stäber CLA 2017-07-05 13:52:15 EDT
I originally reported this bug here https://github.com/eclipse/eclipse.jdt.ls/issues/291, and was asked to open an upstream bug for the Eclipse compiler:

The following code yields a syntax error although the code is correct:

    ElementMatcher.Junction<MethodDescription> junction = ElementMatchers
            .named(method.getMethodName())
            .and(not(isAbstract()))
            .and(isPublic())
            .and(takesArguments(method.getParameterTypes().size()));

The error reported in the first line of the snippet is:

    file: 'file:///Users/fabian/workspace/promagent/promagent-internal/src/main/java/io/promagent/internal/Promagent.java'
    severity: 'Error'
    message: 'Type mismatch: cannot convert from ElementMatcher.Junction<MethodDescription & NamedElement & ModifierReviewable.OfAbstraction> to ElementMatcher.Junction<MethodDescription>'
at: '83,71'
    source: 'Java'

The code can be found in commit 8a6655e3e4d034193634d51025baca1ca079a72f here: https://github.com/fstab/promagent/blob/master/promagent-internal/src/main/java/io/promagent/internal/Promagent.java#L83-L87

The code looks fine in Intellij, compiles without problems with Maven, and runs well, so it's probably a bug in the Eclipse compiler.
Comment 1 Fred Bricon CLA 2017-07-05 13:55:04 EDT
Bug can be reproduced in Eclipse Oxygen
Comment 2 Stephan Herrmann CLA 2017-07-05 14:13:28 EDT
Type compatibility involving intersection types is not a trivial thing. Will analyze which compiler is right or wrong after Java 9 has sailed.
Comment 3 Manoj N Palat CLA 2018-05-17 03:24:48 EDT
bulk move out of 4.8
Comment 4 Manoj N Palat CLA 2018-08-16 00:06:34 EDT
Bulk move out of 4.9
Comment 5 Stephan Herrmann CLA 2018-08-16 05:07:00 EDT
I'd be willing to make a quick investigation if s.o. would provide a self-contained example.
Comment 6 Eclipse Genie CLA 2022-06-20 09:56:36 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.