matthiasblaesing commented on issue #7800:
URL: https://github.com/apache/netbeans/issues/7800#issuecomment-3192560442

   @homberghp I had a look at your PR and I don't think that the test address 
the point opened here. In fact I think this is not a bug. The provided code is 
incomplete so I took the code and made it executable:
   
   ```java
   public class TestX {
   
       static class ParentClass {
   
           void method() {
               System.out.println("ParentClass method");
           }
       }
   
       static class A extends SubClass {
   
           void method() {
               System.out.println("Class A method");
           }
       }
   
       static class SubClass extends ParentClass {
   
           void test() {
               method();
           }
       }
   
       public static void main(String[] argv) {
           A a = new A();
           a.test();
       }
   }
   ```
   
   now @assdfsdafasfa  writes:
   
   > before refactoring, test() method calls method() of class ParentClass, 
after refactoring, test() method calls method() of class SubClass
   
   this is a wrong assumption. As `method` is overriden in `A` calls to 
`method` invoked on an instance of `A` will always yield `Class A method`. It 
does not matter that `method` is called via `SubClass#test`.
   
   Running the above code yields:
   
   ```
   --- exec:1.5.0:exec (default-cli) @ MavenSpielwiese ---
   Class A method
   ```
   
   Running "Push down" refactoring yields (as described in the issue):
   
   ```java
   public class TestX {
   
       static class ParentClass {
   
           void method() {
               System.out.println("ParentClass method");
           }
       }
   
       static class A extends SubClass {
   
           void method() {
               System.out.println("Class A method");
           }
   
           void test() {
               method();
           }
       }
   
       static class SubClass extends ParentClass {
       }
   
       public static void main(String[] argv) {
           A a = new A();
           a.test();
       }
   }
   ```
   
   And that yields unsurprisingly:
   
   ```
   --- exec:1.5.0:exec (default-cli) @ MavenSpielwiese ---
   Class A method
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to