class: ClassBuilder
authorStefan Vogel <sv@exept.de>
Fri, 27 Mar 2015 11:41:00 +0100
changeset 17695 2f478cffbfab
parent 17694 945674595bd0
child 17696 bdccf4ca66ba
class: ClassBuilder changed: #fixMethodsIn: when adding instance variables at the end: only try to recompile methods possibly accesing these new instavars if a global or class var with the same name exists. (So we can install patches with new instvars)
ClassBuilder.st
--- a/ClassBuilder.st	Fri Mar 27 10:24:52 2015 +0100
+++ b/ClassBuilder.st	Fri Mar 27 11:41:00 2015 +0100
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
 "
  COPYRIGHT (c) 2001 by eXept Software AG
               All Rights Reserved
@@ -907,15 +909,14 @@
 
     changeSet1 := Set new.
 
-    classVarChange := classVarChange ? false.
-    instVarChange := instVarChange ? false.
+    classVarChange := false.
 
     superClassChange ifTrue:[
         (oldSuperClass notNil
         and:[newSuperClass notNil
         and:[oldSuperClass allClassVarNames = newSuperClass allClassVarNames
         and:[oldSuperClass name = newSuperClass name
-        and:[(oldClassVars sameContentsAs: newClassVars)
+        and:[oldClassVars = newClassVars
         and:[poolChange not]]]]])
         ifTrue:[
 
@@ -1064,8 +1065,7 @@
                 self class copyMethodsFrom:oldClass for:newClass
             ]
         ] ifTrue:[
-
-            "/ dont allow built-in classes to be modified
+            "/ don't allow built-in classes to be modified
 
             (instVarChange and:[oldClass notNil and:[oldClass isBuiltInClass]]) ifTrue:[
                 ClassBuildError raiseErrorString:'The layout of this class is fixed - you cannot change it.'.
@@ -1074,7 +1074,6 @@
 
             ((oldInstVars size == 0) 
             or:[newInstVars startsWith:oldInstVars]) ifTrue:[
-
                 "/ only new inst variable(s) has/have been added - 
                 "/ old methods still work (the existing inst-indices are still valid)
 
@@ -1090,12 +1089,14 @@
                 "merge in class variables"
                 changeSet1 do:[:nm | addedNames add:nm].
 
-"/                Smalltalk silentLoading ifFalse:[
-"/                    Transcript showCR:'recompiling instance methods accessing ' , addedNames printString ,  '... [added instvars]'.
-"/                    Transcript endEntry.
-"/                ].
-
-                newClass recompileMethodsAccessingAny:addedNames.
+                (addedNames contains:[:eachAddedName| (Smalltalk at:eachAddedName asSymbol) notNil 
+                                                        or:[(oldClass whichClassDefinesClassVar:eachAddedName) notNil]]) ifTrue:[
+"/                    Smalltalk silentLoading ifFalse:[
+"/                        Transcript showCR:'recompiling instance methods accessing ' , addedNames printString ,  '... [added instvars]'.
+"/                        Transcript endEntry.
+"/                    ].
+                    newClass recompileMethodsAccessingAny:addedNames.
+                ].
             ] ifFalse:[
 
                 "/ the changeset consists of instance variables, 
@@ -2395,11 +2396,11 @@
 !ClassBuilder class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/ClassBuilder.st,v 1.135 2015-02-25 23:10:14 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/ClassBuilder.st,v 1.136 2015-03-27 10:41:00 stefan Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic/ClassBuilder.st,v 1.135 2015-02-25 23:10:14 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/ClassBuilder.st,v 1.136 2015-03-27 10:41:00 stefan Exp $'
 ! !