Smalltalk.st
changeset 5610 af0d91fe32fc
parent 5601 c101570d9daa
child 5611 50e56ee5a70c
--- a/Smalltalk.st	Fri Sep 15 19:58:54 2000 +0200
+++ b/Smalltalk.st	Sat Sep 16 20:41:03 2000 +0200
@@ -1023,9 +1023,10 @@
 
     |oldName oldSym newSym names oldCVSym newCVSym value oldNameToNewName
      oldNameSpace newNameSpace oldBaseName newBaseName privateClasses
-     oldBaseNameWithoutPrefix newBaseNameWithoutPrefix i1 i2 nm ns subns|
-
-    "/ check for all intermediate namespaces
+     oldBaseNameWithoutPrefix newBaseNameWithoutPrefix i1 i2 nm ns subns
+     oldMetaclass newMetaclass|
+
+    "/ check for all intermediate namespaces / owning classes
     i1 := 1.
     i2 := 1.
     ns := self.
@@ -1075,6 +1076,33 @@
 
     self at:oldSym put:nil.
 
+    "/ change the owning class
+    ns isNameSpace ifFalse:[
+        aClass isPrivate ifTrue:[
+            aClass class setOwningClass:ns.
+        ] ifFalse:[
+            oldMetaclass := aClass class.
+
+            "/ sigh - must make a PrivateMetaclass from Metaclass
+            newMetaclass := PrivateMetaclass new.
+            newMetaclass flags:(oldMetaclass flags).
+            newMetaclass setSuperclass:(oldMetaclass superclass).
+            newMetaclass instSize:(oldMetaclass instSize).
+            newMetaclass setInstanceVariableString:(oldMetaclass instanceVariableString).
+            newMetaclass setMethodDictionary:(oldMetaclass methodDictionary).
+            newMetaclass setSoleInstance:aClass.
+            newMetaclass setOwningClass:ns.
+
+            aClass changeClassTo:newMetaclass.
+            self flushCaches.
+        ]
+    ] ifTrue:[
+        aClass isPrivate ifTrue:[
+            self halt.
+            aClass class setOwningClass:nil.
+        ]        
+    ].
+
     "/
     "/ see comment in #removeKey: on why we dont remove it it here
     "/
@@ -5765,5 +5793,5 @@
 !Smalltalk class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Smalltalk.st,v 1.467 2000-09-12 10:17:43 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Smalltalk.st,v 1.468 2000-09-16 18:41:03 cg Exp $'
 ! !