[BUG][FIX]: ClassBuilder>>validateSubclassFormat:from:forSuper
:extra:
Florin X Mateoc
mateoc_florin at jpmorgan.com
Fri Nov 12 20:34:25 UTC 1999
The following code fragment at the end of the method is not entirely correct:
"And check if the immediate subclasses of oldClass can keep its layout"
oldClass subclassesDo:[:sub|
oldType _ sub typeOfClass.
oldType == newType ifFalse:[
self error: sub name,' cannot be recompiled'.
^false]].
Why should the subclasses of oldClass have the same type as the new type of
oldClass (their superclass) ? Perhaps they never had the same type, in which
case this will fail for any refactoring. A small testcase follows:
Object subclass: #A
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Kernel-Objects'.
Object subclass: #B
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Kernel-Objects'.
B variableSubclass: #Sub
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Kernel-Objects'.
Now the innocent refactoring ...
A subclass: #B
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Kernel-Objects'.
.... will fail.
The types only need to be the same if the new type of oldClass is variable,
therefore the easy fix:
newType ~~ #normal ifTrue:
"Check if the immediate subclasses of oldClass can keep its layout"
[oldClass subclassesDo:[:sub|
oldType _ sub typeOfClass.
oldType == newType ifFalse:[
self error: sub name,' cannot be recompiled'.
^false]]].
Florin
More information about the Squeak-dev
mailing list
|