Bug 499026 - Issue with ecj Types.asMemberOf() and Generics
Summary: Issue with ecj Types.asMemberOf() and Generics
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: APT (show other bugs)
Version: 4.7   Edit
Hardware: PC Linux
: P3 normal with 6 votes (vote)
Target Milestone: ---   Edit
Assignee: Generic inbox for the JDT-APT component CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2016-08-02 04:46 EDT by Jean-Marie HENAFF CLA
Modified: 2023-01-07 17:21 EST (History)
4 users (show)

See Also:


Attachments
Sample project to reproduce the issue (2.23 MB, application/gzip)
2016-08-02 04:46 EDT, Jean-Marie HENAFF CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jean-Marie HENAFF CLA 2016-08-02 04:46:14 EDT
Created attachment 263415 [details]
Sample project to reproduce the issue

I've attached a sample project to reproduce the issue.

Execute run.sh and the following error message should appear:

1. ERROR in /tmp/test/Sample/src/com/test/src/Test.java (at line 0)
	/*
	^
Internal compiler error: java.lang.Exception: java.lang.IllegalArgumentException: element public void set(T)  is not a member of the containing type com.test.src.GenericChild<com.test.src.Test.MyTypeChild> nor any of its superclasses at org.eclipse.jdt.internal.compiler.apt.dispatch.RoundDispatcher.handleProcessor(RoundDispatcher.java:169)
----------
1 problem (1 error)


The test calls Types.asMemberOf() to get method "void set(T t)" (defined in GenericSuper<T>) from a parameterized type of a field declared as GenericChild<MyTypeChild>, with

public class GenericChild<T extends MyType> extends GenericSuper<T> {

}

where method is seen as "void set(com.test.src.Test.MyTypeChild)". then areParameterErasuresEqual() fails to find a match.

What seemed to work but might not be the right way to fix this, is to change TypesImpl.asMemberOf() from:

                    MethodBinding methodBinding = ((MethodBinding) memberBinding);
                    for (MethodBinding method : typeBinding.methods()) {
                      if (CharOperation.equals(method.selector, methodBinding.selector)
                          && (method.original() == methodBinding
                              || method.areParameterErasuresEqual(methodBinding))) {
                        return TypesImpl.this._env.getFactory().newTypeMirror(method);
                      }
                    }

to

                    MethodBinding methodBinding = ((MethodBinding) memberBinding).original();
                    for (MethodBinding methodG : typeBinding.methods()) {
                      MethodBinding method = methodG.original();
                      if (CharOperation.equals(method.selector, methodBinding.selector)
                          && (method.original() == methodBinding
                              || method.areParameterErasuresEqual(methodBinding))) {
                        return TypesImpl.this._env.getFactory().newTypeMirror(methodG);
                      }
                    }
Comment 2 Jay Arthanareeswaran CLA 2017-01-09 11:59:53 EST
(In reply to Jean-Marie HENAFF from comment #1)
> Forgot link to switch statement:
> 
> https://git.eclipse.org/c/jdt/eclipse.jdt.core.git/tree/org.eclipse.jdt.
> compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/TypesImpl.
> java#n77

You probably meant this for bug 510118?
Comment 3 Jean-Marie HENAFF CLA 2017-01-09 12:04:37 EST
Oops yes sorry, I just noticed it wasn't in the other but report, thanks.
Comment 4 Victor Noël CLA 2018-07-24 02:44:58 EDT
Any plan to get this fixed?
Comment 5 Jay Arthanareeswaran CLA 2018-07-24 02:55:57 EDT
I see that there's already a suggestion for fix, which IMO might be the right way to too. Will see if the effort is small.
Comment 6 Eclipse Genie CLA 2020-08-30 18:29: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.
Comment 7 Eclipse Genie CLA 2023-01-07 17:21:09 EST
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.