Bug 296660

Summary: [compiler] Incorrect unused method warning from compiler
Product: [Eclipse Project] JDT Reporter: Srikanth Sankaran <srikanth_sankaran>
Component: CoreAssignee: Srikanth Sankaran <srikanth_sankaran>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: eclipsebugs, jarthana
Version: 3.5   
Target Milestone: 3.6 M4   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Proposed patch none

Description Srikanth Sankaran CLA 2009-12-01 22:17:13 EST
[Follow up of bug#283031 comment#16]

Eclipse Version: 3.6.0, Build id: I20091030-1201.

The following code produces an incorrect unused method warning:

public class EclipseBug {
    private static class A {
        public void foo() {} // <-- gets flagged
    }
    public static class B extends A {}
}

while the message is "technically" correct i.e foo is never used "locally",
one of the quick fix provided viz,  "Remove method foo" could lead to build
errors if method foo was used elsewhere.
Comment 1 Srikanth Sankaran CLA 2009-12-02 01:48:50 EST
Created attachment 153560 [details]
Proposed patch
Comment 2 Peter Arrenbrecht CLA 2009-12-02 02:00:23 EST
(In reply to comment #0)
> while the message is "technically" correct i.e foo is never used "locally",
> one of the quick fix provided viz,  "Remove method foo" could lead to build
> errors if method foo was used elsewhere.

Huh? The "unused locally" warning means what it says -and- that the element in question is not visible outside. Otherwise you would have to flag all public methods of any class as "unused locally", unless they are used by the class itself. So this is not a bug just because of the quick fix.
Comment 3 Srikanth Sankaran CLA 2009-12-02 03:13:24 EST
(In reply to comment #2)
> (In reply to comment #0)
> > while the message is "technically" correct i.e foo is never used "locally",
> > one of the quick fix provided viz,  "Remove method foo" could lead to build
> > errors if method foo was used elsewhere.
> Huh? The "unused locally" warning means what it says -and- that the element in
> question is not visible outside. Otherwise you would have to flag all public
> methods of any class as "unused locally", unless they are used by the class
> itself. So this is not a bug just because of the quick fix.

Yes, I was not suggesting this is a bug only because of the offered
quick fix. The quick fix was mentioned because, whenever something
is flagged as unused, you should be able to delete it without any
deleterious effect and that is not guaranteed in this case.

As for the first part, it is perhaps splitting hairs on my part, I was
merely pointing out that the message literally is not incorrect. When
viewed in the larger context of this diagnotic being useful however, it
needs fixing and hence this bug.
Comment 4 Srikanth Sankaran CLA 2009-12-02 03:31:41 EST
Released in HEAD for 3.6M4
Comment 5 Jay Arthanareeswaran CLA 2009-12-08 01:25:18 EST
Verified for 3.6M4 using build I20091207-1800