Recompile methods when changing classVars.
authorStefan Vogel <sv@exept.de>
Fri, 23 Jan 1998 19:01:13 +0100
changeset 3220 923707e8d156
parent 3219 33b5d79b32ff
child 3221 21085ae8e1be
Recompile methods when changing classVars.
Class.st
--- a/Class.st	Fri Jan 23 18:58:05 1998 +0100
+++ b/Class.st	Fri Jan 23 19:01:13 1998 +0100
@@ -461,16 +461,22 @@
 
 addClassVarName:aString
     "add a class variable if not already there and initialize it with nil.
-     Also writes a change record and notifies dependents.
-     BUG: Currently, no recompilation is done - this will change."
+     Also writes a change record and notifies dependents."
 
     (self classVarNames includes:aString) ifFalse:[
-	self classVariableString:(self classVariableString , ' ' , aString).
-	self addChangeRecordForClass:self.
-	self changed:#definition.
+        self classVariableString:(self classVariableString , ' ' , aString).
+        Class withoutUpdatingChangesDo:[
+            self withAllSubclasses do:[:cls|
+                cls recompileMethodsAccessingAnyClassvarOrGlobal:
+                                        (Array with:aString asSymbol)
+            ].
+        ].
+        self addChangeRecordForClass:self.
+        self changed:#definition.
     ]
 
-    "Created: 29.10.1995 / 19:40:51 / cg"
+    "Created: / 29.10.1995 / 19:40:51 / cg"
+    "Modified: / 23.1.1998 / 15:46:23 / stefan"
 !
 
 category
@@ -944,14 +950,21 @@
 
     names := self classVarNames.
     (names includes:aString) ifTrue:[
-	newNames := ''.
-	names do:[:nm | nm ~= aString ifTrue:[newNames := newNames , nm , ' ']].
-	self classVariableString:newNames withoutSpaces.
-	self addChangeRecordForClass:self.
-	self changed:#definition.
+        newNames := ''.
+        names do:[:nm | nm ~= aString ifTrue:[newNames := newNames , nm , ' ']].
+        self classVariableString:newNames withoutSpaces.
+        Class withoutUpdatingChangesDo:[
+            self withAllSubclasses do:[:cls|
+                cls recompileMethodsAccessingAnyClassvarOrGlobal:
+                                        (Array with:aString asSymbol)
+            ].
+        ].
+        self addChangeRecordForClass:self.
+        self changed:#definition.
     ]
 
-    "Created: 29.10.1995 / 19:42:08 / cg"
+    "Created: / 29.10.1995 / 19:42:08 / cg"
+    "Modified: / 23.1.1998 / 15:46:33 / stefan"
 !
 
 setClassFilename:aFilename
@@ -3916,5 +3929,5 @@
 !Class class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Class.st,v 1.299 1998-01-16 14:59:43 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Class.st,v 1.300 1998-01-23 18:01:13 stefan Exp $'
 ! !