Bug 143616 - [extract method] problem with shadowed subclass methods
Summary: [extract method] problem with shadowed subclass methods
Status: ASSIGNED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.1.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2006-05-24 18:09 EDT by Emerson Murphy-Hill CLA
Modified: 2023-05-20 10:28 EDT (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 Emerson Murphy-Hill CLA 2006-05-24 18:09:10 EDT
Take the following two classes:

public class ExtractMethodDemo extends SuperClass {
 private String subMethod(){
  return "SubClass";
 }
}

class SuperClass{
 public String someMethod(){
  //extract from here...
  return "SuperClass";
  //...to here
 }
}

Run Extract Method on the indicated piece of code, calling the new method "subMethod" and setting it to public.

Code no longer compiles!  You can get a similar effect by making the extracted function's return type different from the return type of the shadowed method.
Comment 1 Olivier Thomann CLA 2006-05-24 20:55:45 EDT
Move to JDT/UI
Comment 2 Benjamin Muskalla CLA 2009-08-01 17:29:33 EDT
Currently the refactoring correctly warns you if you try to introduce a new method in a subclass if it has the same signature as a method in the superclass. Comment 0 states the opposite direction which is currently not warned. Markus, thinking of javas open-world assumption, should we warn the user in this case?
Comment 3 Eclipse Genie CLA 2019-04-30 18:11:44 EDT
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 4 Dani Megert CLA 2019-05-01 08:46:31 EDT
Still a problem in 4.12 M1.
Comment 5 Eclipse Genie CLA 2021-04-21 10:14:27 EDT
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 6 Eclipse Genie CLA 2023-05-20 10:28:12 EDT
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.