Bug 268665 - [change method signature] misleading error message when removing unused parameter of recursive function
Summary: [change method signature] misleading error message when removing unused param...
Status: ASSIGNED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows XP
: P3 minor with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: helpwanted
: 137175 408387 (view as bug list)
Depends on:
Blocks:
 
Reported: 2009-03-15 07:52 EDT by Michael Schierl CLA
Modified: 2023-12-25 07:07 EST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Schierl CLA 2009-03-15 07:52:26 EDT
Build ID: I20080617-2000

Steps To Reproduce:
1. Start with this class:

public class RecursiveMethodSignature {

	public static void main(String[] args) {
		System.out.println(factorial(42, false));
	}

	// try to remove "dummy" parameter here
	private static int factorial(int n, boolean dummy) {
		if (n < 2)
			return 1;
		else
			return n * factorial(n-1, dummy);
	}
}

2. Invoke "Change method signature" on factorial method.
3. Remove the "dummy" parameter and click ok.

Actual Result:
You get an error that the removed parameter is still used. If you continue anyway, no error remains since the parameter is only used in the recursive call.

Expected Result:
There should be no error. Maybe a warning.

More information:
In the current state, as I cannot rely on this errors in the preview, I usually ignore this error and look what happens. It would be nice if I could rely on that error - i. e. it only appears if there will really be an error present afterwards.
Comment 1 Dani Megert CLA 2009-03-16 05:11:09 EDT
Also happens for non-static methods.

Simpler test case:
        // try to remove parameter 'n'
        private  int foo(int n) {
                return foo(n);
        }
Comment 2 Markus Keller CLA 2009-03-16 08:53:16 EDT
*** Bug 137175 has been marked as a duplicate of this bug. ***
Comment 3 Dani Megert CLA 2013-05-21 08:22:11 EDT
*** Bug 408387 has been marked as a duplicate of this bug. ***
Comment 4 Stephan Herrmann CLA 2013-05-21 08:52:55 EDT
(In reply to comment #3)
> *** Bug 408387 has been marked as a duplicate of this bug. ***

I'm not sure why I didn't find this bug.
Thanks for the cross-ref.

Note, that bug 408387 comment 1 has some pondering about implementation strategies.
Comment 5 Markus Keller CLA 2013-05-21 12:18:20 EDT
The TempOccurrenceAnalyzer in ChangeSignatureProcessor.DeclarationUpdate.checkIfDeletedParametersUsed() should do something similar to ReferenceUpdate.isRecursiveReference() and handle method references specially if they point back to the original method. Arguments for parameters that will be deleted should be skipped. Don't forget about varargs.

(In reply to bug 408387 comment #1)
We usually do the analysis independent of the actual rewrite. Just depending on nodes that are deleted by an ASTRewrite is brittle, since the nodes could be deleted for many reasons (e.g. because they are moved to another place).
Comment 6 Eclipse Genie CLA 2019-12-27 15:32:37 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.
Comment 7 Michael Schierl CLA 2019-12-27 19:04:51 EST
For the record: Still happens in 2019-12, still relevant for me.

But probably I'll have to write the same again in 2029...
Comment 8 Dani Megert CLA 2019-12-28 11:58:42 EST
(In reply to Michael Schierl from comment #7)
> For the record: Still happens in 2019-12, still relevant for me.
> 
> But probably I'll have to write the same again in 2029...
Right, unless you or someone else provides a fix ;-).
Comment 9 Eclipse Genie CLA 2021-12-18 19:34:52 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.
Comment 10 Michael Schierl CLA 2022-01-02 09:17:20 EST
For the record: Still happens in 2022-12, still relevant for me.

(The Genie is getting more aggressive, complaining after 2 years now and not after 10)
Comment 11 Eclipse Genie CLA 2023-12-24 14:40:05 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.
Comment 12 Michael Schierl CLA 2023-12-25 07:07:54 EST
For the record: Still happens in 2023-12, still relevant for me. See you in two years :D