Re: Copying classes: breaking contract or not?
Posted by
Eliot Miranda-2 on
May 15, 2012; 4:33pm
URL: https://forum.world.st/Copying-classes-breaking-contract-or-not-tp4628606p4630336.html
On Sat, May 12, 2012 at 3:05 AM, Mariano Martinez Peck
<[hidden email]> wrote:
Hi guys. The last literal of a instance-side compiled method always points to the SAME (#==) association of the class in Smalltalk global.
The literals of a compiled method that refer to class variables refer to the same association (#==) of the classPool of its class:
self assert: ((GRPlatform class >> #current) literalAt: 1) == (GRPlatform classPool associationAt: #Current). -> true
However, if I do a copy of the class:
| copy |
copy := GRPlatform copy.
self assert: ((copy class >> #current) literalAt: 1) == (copy classPool associationAt: #Current).
this is not true anymore. Of course, you can see this because of the Class >> #copy implementation:
So my question is....is #copy breaking the contract (and therefore it has to be fixed) or this is not mandatory for the system (as it is with the last literal pointing to classes)?
Yes. Class>>copy: is broken. Not changing the associations (on the class side as well) at the very least breaks super sends.
--
best,
Eliot