Closed tsdh closed 9 years ago
The decision whether two method implementations are equal is a decision made by the developer who assigned the refactoring. (In our case who designed the test case)
This decision is even with much more information than contained in the PG undecidable.
Accordingly there are no test cases provided by us in which the equality of method definitions is tested or has to be decided.
Ok, perfect.
I don't see how the pre-conditions of the pull up method refactoring can be checked on the PG because the information on having "equivalent functionality" isn't contained in there.
Example:
Here,
B
andC
have a common superclass and theirfoo
methods have identical signatures and access no members ofB
orC
, so thefoo
method is a candidate for pulling up. However, they don't have equivalent functionality. That's not checkable in the PG. How to deal with that?One could try to check that by going back to the original Java code/AST in order to check if the method bodies are equal. But that would require that you have to define an equality operator for any AST class whose instances might occur in a method body and that's almost everything. (You might be better off if you can serialize the bodies back to Java, canonicalize them, and then compare the strings but AFAICS at least JaMoPP which I use here doesn't seem to have that functionality as part of its public API.)
Another problematic example is:
Again, the
foo
method is a candidate for pulling up. But from a programmer's POV pulling up according to the case description is wrong here. It might be ok to pull up the abstract method but the concrete implementation inC
must not be deleted. But there are no modifiers anymore in the PG.