[Backport] Port fixes on traits and metaclasses to Pharo 12#16776
Merged
MarcusDenker merged 7 commits intopharo-project:Pharo12from Jun 20, 2024
Merged
[Backport] Port fixes on traits and metaclasses to Pharo 12#16776MarcusDenker merged 7 commits intopharo-project:Pharo12from
MarcusDenker merged 7 commits intopharo-project:Pharo12from
Conversation
If you have a class using traits, its metaclass will be TraitedMetaclass. Now, if you remove its traits, its class should be Metaclass. The problem is that if you use #fillFor: it will not be the case. The origin of the problem comes from the fact that #fillFor: will set the metaclass class to TraitedMetaclass and this will not be updated if you set the trait composition to be empty. I provided a fix that is not so good in my opinion, but I'll try to change the way the class builder deals with metaclass class later to simplify this system and remove the need of this fix. Finally I moved a test from shift class builder tests to traits tests since it uses a trait
…metaclass class selected
Imagine you have two traits T1 and T2. You also have a class C1 using T1 and a class C2 subclassing C1 and using T2. Now if you remove T1 from C1 a bug causes C2 to also lose its trait T2. The bug comes from the fact that in the trait implementation we copy methods from TraitedMetaclass and TraitedClass in the class using traits. But only in the top most class. Thus, if we update the superclass and it does not have the traits methods anymore, then all subclasses also loses this API. My proposed fix is to keep a flag to know if a class update makes it go from a TraitedMetaclass to another metaclass class and if this flag is true, we update the method dictionaries of the subclasses to get the methods from TraitedMetaclass and TraitedClass. I added a test to check this
MarcusDenker
approved these changes
Jun 20, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport fixes of #16739 and #16722