pharo icon indicating copy to clipboard operation
pharo copied to clipboard

RBAddMethodTransformation does not add changes to the model

Open hernanmd opened this issue 1 year ago • 7 comments

Bug description In RBAddMethodTransformation>>privateTransform a new method is compiled but the change is not recorded into the model, making performChanges later (for example sending execute to the transformation) to not find any changes.

Expected behavior

This is a possible fix

privateTransform

	self model changes addChange: (
		self definingClass
			compile: sourceCode
			classified: protocol)

hernanmd avatar Mar 25 '24 19:03 hernanmd

In #16347

hernanmd avatar Mar 25 '24 20:03 hernanmd

Tx hernan!

Ducasse avatar Mar 25 '24 20:03 Ducasse

I don't think that proposed solution is in line with how other refactorings create changes. We should look into self definingClass and also #compile:classified and see why the change is not added in the model.

balsa-sarenac avatar Mar 29 '24 13:03 balsa-sarenac

I don't think that proposed solution is in line with how other refactorings create changes. We should look into self definingClass and also #compile:classified and see why the change is not added in the model.

Sorry I don't understand what you mean. What would be the problem?

hernanmd avatar Mar 29 '24 13:03 hernanmd

I meant that we never call #addChange: directly in the refactoring. Doing it like that would be a hack. We should investigate and figure out why exactly the model doesn't have this change. I'm not sure what would be the problem, but I've pointed out a few starting points in the comment above.

balsa-sarenac avatar Apr 01 '24 11:04 balsa-sarenac

Hey Hernan, where did you discover this bug, how can I reproduce it?

balsa-sarenac avatar Apr 08 '24 09:04 balsa-sarenac

@hernanmd we debugged and the fix is:

RBMakeClassAbstractTransformation >> privateTransform

	self generateChangesFor: (RBAddMethodTransformation
		 sourceCode: 'isAbstract

	^ self == ' , targetClass asString
		 in: targetClass classSide
		 withProtocol: #testing)

previously it was using execute which immediately compiled the method vs. now the change is in the model.

balsa-sarenac avatar Apr 11 '24 12:04 balsa-sarenac