[squeak-dev] Class subclasses

Florin Mateoc florin.mateoc at gmail.com
Fri Jun 13 02:32:52 UTC 2014


On 6/12/2014 1:56 PM, Frank Shearar wrote:
> On 12 June 2014 04:44, Florin Mateoc <florin.mateoc at gmail.com> wrote:
>> Hi,
>>
>> I think this is an old bug, presumably since ProtoObject was introduced (and presumably because ObjectTracer was used in
>> the process).
>>
>> If you ask Class for its subclasses (or if you inspect it) you see that ObjectTracer class is listed along with
>> ProtoObject class, although ObjectTracer's superclass is ProtoObject.
>> This can lead to some funny bugs if you try to write some hierarchy traversing code.
> ObjectTracer's superclass is ProtoObject, as you say, but ObjectTracer
> class's superclass is indeed Class. (Indeed, ProtoObject class
> superclass == Class.)

No, ObjectTracer class' superclass is not Class but ProtoObject class, paralleling its class hierarchy. That's exactly
the problem. Although ObjectTracer class' superclass is not Class, Class claims that ObjectTracer class is a direct
subclass. On the other hand if you evaluate ProtoObject class subclasses it also contains ObjectTracer class (that's a
direct consequence of ObjectTracer being a subclass of ProtoObject, metaclasses don't store their subclasses). So now
you have two different behaviors claiming ObjectTracer class as their direct subclass.
This bug could happen because classes cache their subclasses in an instvar and theoretically that information can become
stale - it even happened in practice in this case.

In general, only nil subclasses have their class side direct Class subclasses.

> So I'm not sure I understand the nature of the problem: metaclasses
> are usually Class subclasses.

But not direct subclasses.

>
> Aren't those funny bugs to do with the (unavoidable) singularity at
> the top of both hierarchies?
>
> frank
>
>> Cheers,
>> Florin
>>
> .
>



More information about the Squeak-dev mailing list