Bug 69555 - Local variable declaration hides another field or variable
Summary: Local variable declaration hides another field or variable
Status: RESOLVED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: polish, ui
Depends on:
Blocks:
 
Reported: 2004-07-07 20:59 EDT by Daniel CLA
Modified: 2009-08-30 02:21 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 Daniel CLA 2004-07-07 20:59:22 EDT
When the preference :

Window -> Preferences -> Java -> Compiler -> Advanced ->
Local variable declaration hides another field or variable

is set to warning, it highlights the parameter 'bar' of the abstract method 
'foobar' in the following code :

----- BEGIN -----
1: public abstract class Foo {
2:
3:   private int bar;
4:   
5:   protected abstract void foobar(int bar);
6:
7:   }
----- END -----

I believe that since the instance variable 'bar' will never be seen in the 
concretization of 'foobar' (in a subclass), the engine responsible should not 
issue a 'Local variable declaration hides another field or variable' warning.
Comment 1 Philipe Mulet CLA 2004-07-08 06:52:07 EDT
I suppose we could implement the fact that methods without no body would not 
be flagged (abstract or native).
Comment 2 Michael Fraenkel CLA 2004-07-11 18:41:51 EDT
Something like the following??


Index: Argument.java
===================================================================
RCS 
file: /home/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/comp
iler/ast/Argument.java,v
retrieving revision 1.38
diff -u -r1.38 Argument.java
--- Argument.java	6 Jul 2004 11:15:03 -0000	1.38
+++ Argument.java	11 Jul 2004 22:33:23 -0000
@@ -37,6 +37,9 @@
 		// record the resolved type into the type reference
 		int modifierFlag = this.modifiers;
 
+		if ((scope.getDeclarationModifiers() & (AccAbstract | 
AccNative)) != 0)
+			return;
+		
 		Binding existingVariable = scope.getBinding(name, 
BindingIds.VARIABLE, this, false /*do not resolve hidden field*/);
 		if (existingVariable != null && existingVariable.isValidBinding
()){
 			if (existingVariable instanceof LocalVariableBinding 
&& this.hiddenVariableDepth == 0) {
Comment 3 Philipe Mulet CLA 2004-10-27 12:34:36 EDT
or maybe, we could consider only flagging used variable declarations only.
Comment 4 Philipe Mulet CLA 2005-04-07 09:26:15 EDT
Deferring post 3.1
Comment 5 Denis Roy CLA 2009-08-30 02:21:30 EDT
As of now 'LATER' and 'REMIND' resolutions are no longer supported.
Please reopen this bug if it is still valid for you.