'From Squeak3.6beta of ''4 July 2003'' [latest update: #5395] on 23 August 2003 at 4:46:23 pm'! "Change Set: ClassRenameFix Date: 23 August 2003 Author: Roel Wuyts Calling SystemDictionary>>renameClass:as: resulted in a corrupted systemdictionary. Problem was that this wa actually a kind of private method that was not supposed to be called. This changeset fixes this bug by making the method safe to use. There is an associated SUnit test."! !Class methodsFor: 'class name' stamp: 'rw 8/23/2003 15:45'! rename: aString "The new name of the receiver is the argument, aString." | newName | (newName _ aString asSymbol) ~= self name ifFalse: [^ self]. (self environment includesKey: newName) ifTrue: [^ self error: newName , ' already exists']. (Undeclared includesKey: newName) ifTrue: [self inform: 'There are references to, ' , aString printString , ' from Undeclared. Check them after this change.']. self environment renameClass: self as: newName! ! !SystemDictionary methodsFor: 'class names' stamp: 'rw 8/23/2003 15:45'! renameClass: aClass as: newName "Rename the class, aClass, to have the title newName." | oldref i | SystemOrganization classify: newName under: aClass category. SystemOrganization removeElement: aClass name. ChangeSet current renameClass: aClass as: newName. oldref _ self associationAt: aClass name. self removeKey: aClass name. oldref key: newName. self add: oldref. "Old association preserves old refs" (Array with: StartUpList with: ShutDownList) do: [:list | i _ list indexOf: aClass name ifAbsent: [0]. i > 0 ifTrue: [list at: i put: newName]]. self flushClassNameCache. aClass setName: newName.! !