dolphinsmalltalk / Dolphin

Dolphin Smalltalk Core Image
MIT License
294 stars 58 forks source link

CopyClassRefactoring broken by d2b8d987e3b73d05c79fd75cfe7b57c3cc3d4c6c #1236

Closed blairmcg closed 7 months ago

blairmcg commented 7 months ago

Since d2b8d987e3b73d05c79fd75cfe7b57c3cc3d4c6c AddClassRefactoring creates a class as described by ClassDetails, and this can include variables. This broke CopyClassRefactoring because it tried to add the variables as well after creating the class with them already defined, and there was a test gap so this went unnoticed.

The refactoring is enhanced to copy the variables of superclasses that it references. This ensures that the copied methods will compile. Any inherited but unreferenced variables are not copied. There might be place for copying down inherited methods that are not overriden and not common, but not for now. This is a refactoring since the existing behaviour of the system is preserved, even if the cloned class is not complete.

The preconditions for AddClassRefactoring should also have been enriched to validate the variables.