Bug 133575 - [inline] method can't find the corresponding method declaration
Summary: [inline] method can't find the corresponding method declaration
Status: RESOLVED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.3   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-03-28 11:16 EST by Benno Baumgartner CLA
Modified: 2009-08-30 02:37 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Benno Baumgartner CLA 2006-03-28 11:16:03 EST
I20060328-0010

Given:
public void foo(Object o) {
	boolean b = o.getClass().isEnum();
}
In a 1.5 project with an 1.5 JRE

1. Select isEnum
2. Inline
->Unable to resolve corresponding method declaration
3. Ctrl-Click on isEnum
->Method declaration is shown

4. Set the compiler compliance level to 1.4 for the project
5. Inline 'isEnum'
->The method declaration contains compile errors. Fix them.
6. Look at probelms view
->No errors
Comment 1 Markus Keller CLA 2006-03-29 07:45:47 EST
The problem is in CompilationUnit#findDeclaringNode(String key).

In InlineMethodRefactoring.java:429, I call that method with key "Lxy/Try;&Ljava/lang/Class<!Ljava/lang/Class;+Ljava/lang/Object;96;>;.isEnum()Z", which comes from the invocation's binding for isEnum().

When I use #findDeclaringNode(methodBinding.getMethodDeclaration().getKey()), then it works. The javadoc tells
"<li>method - a <code>MethodDeclaration</code> </li>" and "for parameterized or raw method bindings, the declaring node is that of the corresponding generic method."

Although the isEnum() is neither a parameterized nor a generic method, I would expect that #findDeclaringNode(..) does the getMethodDeclaration() for me.

The speciality of Object#getClass() does not seem to be the issue, since
    foo(ArrayList<String> as) { boolean b = as.isEmpty(); }
also does not work.
Comment 2 Jerome Lanneluc CLA 2006-04-05 07:26:32 EDT
Not clear if we want to change this since no AST node exists for capture binding. A workaround exists as described in comment 1 (use getMethodDeclaration()).

Will reconsider post 3.2.
Comment 3 Eclipse Webmaster CLA 2009-08-30 02:37:37 EDT
As of now 'LATER' and 'REMIND' resolutions are no longer supported.
Please reopen this bug if it is still valid for you.