[P13] Fix bug while using #superclassName: when updating a class#19574
[P13] Fix bug while using #superclassName: when updating a class#19574jecisc wants to merge 1 commit intopharo-project:Pharo13from
Conversation
Fixes pharo-project#19572 Using #update:to: will set the current superclass to the builder. But #superclassName is ignored if we have a superclass. Here is a fix by flushing #superclass if we set #superclassName. (An alterative would be to have only one variable for both, but I'm not sure of the impact).
| ShiftClassBuilder >> superclassName: anObject [ | ||
|
|
||
| superclass := nil. "In the case we update a class and use #superclassName:, we should flush the superclass saved." | ||
| superclassName := anObject ifNotNil: [ anObject asSymbol ] |
There was a problem hiding this comment.
What is the invariant between superclass and superclassName ?
Because may be we have more hidden bugs.
There was a problem hiding this comment.
The class builder was first designed to take a class as superclass. But then the #superclassName got added in order to be able to give a class name that is not yet in the system.
This is useful when you prepare a bunch of builders to generate multiple classes and some classes inherits from other generating classes (because when we prepare the builder, we don't have the superclass in the system yet).
But maybe we should have the two setter, but only one variable behind? (And #superclass: would do superclassName := aClass name). But for now I just wanted to fix the bug I encountered in Moose
There was a problem hiding this comment.
It is indeed a bit odd. I suggest we fix it like this for now and then check later if we can improve
|
Failing tests seem not related (and it worked in Pharo14) |
I'm proposing to backporting to Pharo 13 because I'll need this fix for a future Moose update