Skip to content
Unstable

Changes

Summary

  1. Fix metaclass of a class after removing its traits (details)
  2. Update the way to declare a metaclass class and fix some bugs in the metaclass class selected (details)
  3. Fix test (details)
  4. Remove unused var (details)
  5. Fix bug causing classes to lose their traits. (details)
  6. Add more tests (details)
Commit 147059f696e3c20b47f2667b925c96a0d26039ba by cyril
Fix metaclass of a class after removing its traits

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
The file was modified src/Traits/ShiftClassBuilder.extension.st (diff)
The file was modified src/Shift-ClassBuilder-Tests/ShClassInstallerTest.class.st (diff)
The file was addedsrc/Traits-Tests/ShTraitInstallerTest.class.st
Commit 93488535c19c5f03270436897a990dc95839e942 by cyril
Update the way to declare a metaclass class and fix some bugs in the metaclass class selected
The file was addedsrc/Traits-Tests/ShTraitBuilderTest.class.st
The file was modified src/Traits/TraitBuilderEnhancer.class.st (diff)
The file was modified src/Shift-ClassBuilder/ShiftClassBuilder.class.st (diff)
The file was modified src/Shift-ClassBuilder/ShDefaultBuilderEnhancer.class.st (diff)
The file was modified src/Traits/ShiftClassBuilder.extension.st (diff)
The file was modified src/Traits/TraitBuilderEnhancer.class.st (diff)
The file was modified src/System-DependenciesTests/SystemDependenciesTest.class.st (diff)
The file was modified src/Shift-ClassBuilder/ShiftClassBuilder.class.st (diff)
Commit 1c6f382b4892ee115f9e304a1a826688565765d7 by cyril
Fix bug causing classes to lose their traits.

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
The file was modified src/Traits-Tests/TraitTest.class.st (diff)
The file was modified src/Traits/TraitBuilderEnhancer.class.st (diff)
The file was modified src/Traits-Tests/TraitTest.class.st (diff)