Is this a bug or it is just my wrong use of the refactoring operation

I try to move a method from its original class to another class. I explain for you the situation by the following example:


The initial situation (before moving the method m):

   The orginal class of the method m:

       class A{

           void n(B b){
               m(b);
           }

            void m(B b){
                 System.out.print("display for me the shape"+this +" " + b.getI() + "times");
           }
        }

    The target class of the method m:

       class B{

           private final int i;

           public B(int i) {
                this.i = i;
           }

           public int getI() {
           return i;
           }

      }

--------- After performing the refactoring operation move, I get the following result:

----- The class A

      class A{
           void n(B b){
               b.m(this);
           }
        }

  --------The class B (here there is a problem to be explaining in the buttom)
       class B{

           private final int i;

           public PrintVisitor(int i) {
                 this.i = i;
            }

           public int getI() {
            return i;
            }

           void m(A a){
                 System.out.print("display for me the shape"+ a +" " + b.getI() + "times");
           }


      }


----------Discussion:
    The problem appears in the class B and exactly in the method expresssion b.getI(), because in the right case the tool should detect automatically when moving the method that it will be getI() instead of b.getI() when the method m takes place in the class B.

My question is: is this a bug or just an ill use from me and if this is a bug I ask if it is possible to correct it because I need to apply the operation move on the case presented above. You should know that I use directly the GUI of the refactoring tool.

2 comments
Comment actions Permalink

I try to move a method from its original class to another class. I explain for you the situation by the following example:


The initial situation (before moving the method m):

   The orginal class of the method m:

       class A{

           void n(B b){
               m(b);
           }

            void m(B b){
                 System.out.print("display for me the shape"+ this+" " + b.getI() + "times");
           }
        }

    The target class of the method m:

       class B{

           private final int i;

           public B(int i) {
                 this.i = i;
            }

           public int getI() {
            return i;
            }

      }

--------- After performing the refactoring operation move, I get the following result:

----- The class A

      class A{
           void n(B b){
               b.m(this);
           }
        }

  --------The class B (here there is a problem to be explaining in the buttom)
       class B{

           private final int i;

           public B(int i) {
                 this.i = i;
            }

           public int getI() {
            return i;
            }

           void m(A a){
                 System.out.print("display for me the shape"+ a +" " + b.getI() + "times");
           }

      }


----------Discussion:
    The problem appears in the class B and exactly in the method  expresssion b.getI(), because in the right case the tool should detect  automatically when moving the method that it will be getI() instead of  b.getI() when the method m takes place in the class B.

My question is: is this a bug or just an ill use from me and if this  is a bug I ask if it is possible to correct it because I need to apply  the operation move on the case presented above. You should know that I use the operation directly from the GUI.

Message was edited by: akram ajouli

0
Comment actions Permalink

The bug is fixed. Thanks

0

Please sign in to leave a comment.