Bug 296660 - [compiler] Incorrect unused method warning from compiler
Summary: [compiler] Incorrect unused method warning from compiler
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.5   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.6 M4   Edit
Assignee: Srikanth Sankaran CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-12-01 22:17 EST by Srikanth Sankaran CLA
Modified: 2009-12-08 01:32 EST (History)
2 users (show)

See Also:


Attachments
Proposed patch (15.40 KB, patch)
2009-12-02 01:48 EST, Srikanth Sankaran CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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