Skip to content

[P13] Fix bug while using #superclassName: when updating a class#19574

Open
jecisc wants to merge 1 commit intopharo-project:Pharo13from
jecisc:kernel/builder13
Open

[P13] Fix bug while using #superclassName: when updating a class#19574
jecisc wants to merge 1 commit intopharo-project:Pharo13from
jecisc:kernel/builder13

Conversation

@jecisc
Copy link
Copy Markdown
Member

@jecisc jecisc commented Apr 17, 2026

I'm proposing to backporting to Pharo 13 because I'll need this fix for a future Moose update

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 ]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the invariant between superclass and superclassName ?
Because may be we have more hidden bugs.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is indeed a bit odd. I suggest we fix it like this for now and then check later if we can improve

@MarcusDenker
Copy link
Copy Markdown
Member

Failing tests seem not related (and it worked in Pharo14)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants