Variables removed from class definition, but still referenced by code

Josh Gargus schwa at fastmail.us
Wed Feb 1 18:00:02 UTC 2006


I have created a changeset in which a class is created with an iVar,  
methods added that reference that iVar, and finally the class  
definition is changed to remove the iVar.  Newly created instances of  
the class behave as though the iVar is still present.

Furthermore, when I add a new subclass that has an iVar of the same  
name, the class compiles OK (if the superclass had explicitly defined  
the iVar, I would not have been able to define it in the subclass).   
However, different slots are being accessed by superclass methods and  
subclass methods.  In the following code (file in the attached  
changeset first):

inst := ClassThatUsedToHaveAVariable new.
inst add: 'string'.
inst contents.

subInst := ClassThatUsedToHaveAVariableSubclass new.
subInst add: 'string2'.
subInst subAdd: 'string3'.
subInst contents.
subInst subContents.


'subInst contents' and 'subInst subContents' do not give the same  
result.  However, if the 'collection' variable is deleted from the  
subclass definition, they do answer the same result.

What exactly are the semantics here?  It seems like this could  
possibly cause some problems.

Thanks,
Josh


  
  
-------------- next part --------------
A non-text attachment was scrubbed...
Name: TestMissingVariable.4.cs.gz
Type: application/x-gzip
Size: 607 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20060201/f3cd66d1/TestMissingVariable.4.cs.bin


More information about the Squeak-dev mailing list