[BUG] ClassBuilder cannot change class to variable subclass
Boris.Gaertner at gmx.net
Sun Jan 4 18:00:23 UTC 2004
This bug report is for Squeak 3.7 alpha latest update: 5623
When you create a subclass, you cannot change it later
into a variable subclass.
To see what goes wrong, please try this:
1. Open a class browser and select class Time.
2. Replace the class name 'Time' with 'TestClass' to
create a subclass of Magnitude. Select 'accept' from
the view menu to create the subclass.
3. Replace the 'subclass:' with 'variableSubclass:'
and 'accept' again to change the just created subclass
into a variable subclass. This should be possible because
'TestClass' has no subclasses at all (subclasses
impose restrictions to the possible type of a class)
and because Magnitude is a fixed-sized class.
You will get a error notifier saying:
'TestClass cannot be compiled'.
The problem is, as far as I can see, in the
method ClassBuilder>>validateSubclassFormat:from: forSuper:extra:
Here we have a check that reads:
[:sub | <omission>
"If we get this far, check whether the immediate
subclasses of oldClass can keep its layout."
(newType ~~ #normal)
[ self validateSubclass: sub
The troublemaker is the "withAllSubclassesDo:".
This method answers a collection that contains
*the receiver class* and all its subclasses.
Therefore, for one evaluation of
'self validateSubclass: ...'
the identity sub == oldClass holds, and this
is clearly not intended.
For the test, we need a collection that contains
only the subclasses of the receiver class, but not
the receiver class itself. Such a collection is
obtained with method 'allSubclassesDo:'.
Attached you find a proposal for a fix. I think that it
will not cause problems elsewhere but your advice
is very welcome.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 1635 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20040104/01c995c1/ClassBuilderCheck-bg.1.obj
More information about the Squeak-dev