| Summary: | [quick fix] QuickFix proposes wrong visibility for overriding/overridden method | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Berthold Daum <berthold.daum> | ||||
| Component: | UI | Assignee: | rgra Missing name <rgransberger> | ||||
| Status: | CLOSED DUPLICATE | QA Contact: | |||||
| Severity: | normal | ||||||
| Priority: | P3 | CC: | Brian.Miller, daniel_megert, eclipse, Lars.Vogel, martinae, matveev, rgransberger | ||||
| Version: | 3.3.1 | ||||||
| Target Milestone: | --- | ||||||
| Hardware: | All | ||||||
| OS: | All | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
Similarly,
package somepackage;
public abstract class Abs {
abstract String getName();
}
---
package notpackage;
public class AbsImpl extends somepackage.Abs {
String getName() {
return "name";
}
}
---
...'s quickfix on AbsImpl#getName() offers to "Change visibility of Abs.getName() to 'default'", which is obviously incorrect, as that's it's current visibility.
*** Bug 271551 has been marked as a duplicate of this bug. *** Created attachment 220032 [details]
Increase visibility if overriding method is private
Please find along a patch which will fix the bug by using the visibility of the overridden method if the overriding method is private instead of proposing to set the overridden method to private.
Thanks for the patch. It fixes comment 0 but not comment 1, which is also reported in bug 65876. In addition there exist similar problems like e.g. bug 87239. I think a fix should be more general and address all those cases once and for all. Comment on the patch: the new variable 'overriddenMethodCU' is a bit overkill and makes the patch bigger than needed. Thx for your feedback, Daniel. I will have a look at it later. If you have any other bugs in mind which you think can be fixed additionally to this here in one go, please post them. I will do a search later too, but I might miss some. (In reply to comment #5) > Thx for your feedback, Daniel. I will have a look at it later. If you have > any other bugs in mind which you think can be fixed additionally to this > here in one go, please post them. I will do a search later too, but I might > miss some. Search for "[quick fix] visibility" in bugzilla (JDT UI component). Should I open a new bug when fixing more than one of these visibility bugs to group them underneath? (In reply to comment #7) > Should I open a new bug when fixing more than one of these visibility bugs > to group them underneath? You can make a so-called root bug which depends on those that you plan to fix. *** This bug has been marked as a duplicate of bug 394692 *** |
Build ID: M20070921-1145 Steps To Reproduce: 1. Create a class A1: public abstract class A1 { protected abstract void m1(); } 2. Create a class B1 public class B1 extends A1 { private void m1() { } } 3. Click the QuickFix. The QuickFix proposes to downgrade the visibility of A1.m1() to private. This conflicts with the abstract nature of A1.m1(). Instead it should propose to upgrade the visibility of B1.m1() to protected. More information: