[squeak-dev] Re: Issue with traits

Andreas Raab andreas.raab at gmx.de
Wed Oct 21 06:42:42 UTC 2009


Igor Stasenko wrote:
> now what i found interesting:
> 
> (ABBAB methodDict at: #foo) == (ABBAC methodDict at: #foo)
> 
> but as side effect, we got this one:
> 
> (ABBAB methodDict at: #foo) methodClass  ==> ABBAC
> 
> which i find a bit disturbing :(

Yes, seems wrong. VERY wrong. Try this:

Object subclass: #BaseA

BaseA>>foo
   ^42

Object subclass: #BaseB

BaseB>>foo
   ^13

And then create subclasses of BaseA and BaseB which use your trait and 
have the trait implementation use "^super foo". One of two things should 
happen:

a) They both return the same (incorrect) value (which would be expected 
if methodClass is the same). In this case it's just plain broken.

b) They both return different values, in which case there is code that 
handles super sends specifically and the sharing is simply an 
unnecessary optimization.

I hope it's the latter case which would mean you only need to throw out 
the test for super sends and do whatever that code was doing to begin 
with ;-)

Cheers,
   - Andreas




More information about the Squeak-dev mailing list