MethodChange.st
changeset 3214 905a4976fac8
parent 3213 56e4caab0075
child 3219 92e64a42ab4e
child 3432 fad2a0fb4f99
--- a/MethodChange.st	Sun Apr 14 09:49:52 2013 +0200
+++ b/MethodChange.st	Sun Apr 14 13:33:33 2013 +0200
@@ -234,7 +234,7 @@
 apply
     "apply the change"
 
-    |class replacementClassName suggestion|
+    |class replacementClassName suggestion oldMethodOrNil oldPackage newPackage defClass|
 
     class := self changeClass.
     class isNil ifTrue:[
@@ -283,6 +283,21 @@
             ]
         ]
     ].
+
+    "/ if overwriting an existing method from another package,
+    "/ put the existing method into the packagessafe
+    oldMethodOrNil := class compiledMethodAt:selector.
+    oldMethodOrNil notNil ifTrue:[
+        oldPackage := oldMethodOrNil package.
+        newPackage := Class packageQuerySignal query.
+        (newPackage notNil and:[newPackage ~= oldPackage]) ifTrue:[
+            defClass := oldPackage asPackageId projectDefinitionClass.
+            defClass notNil ifTrue:[
+                defClass rememberOverwrittenMethod:oldMethodOrNil inClass:class.
+            ]
+        ].
+    ].
+
     class compile:source classified:methodCategory logged:true.
 
     "Modified: / 07-09-2011 / 21:09:19 / cg"
@@ -475,11 +490,11 @@
 !MethodChange class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic3/MethodChange.st,v 1.72 2013-04-14 07:49:52 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic3/MethodChange.st,v 1.73 2013-04-14 11:33:33 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic3/MethodChange.st,v 1.72 2013-04-14 07:49:52 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic3/MethodChange.st,v 1.73 2013-04-14 11:33:33 cg Exp $'
 !
 
 version_SVN