@@ -106,7 +106,39 @@ RwGsPackageSymbolDictionary >> addClassAssociation: assoc toPackageNamed: packag
106
106
{ #category : ' method - patch api' }
107
107
RwGsPackageSymbolDictionary >> addExtensionCompiledMethod: compiledMethod for: behavior protocol: protocolString toPackageNamed: packageName [
108
108
109
-
109
+ | methodDictionary selector protocolSymbol existing loadedMethod loadedPackage loadedClassOrExtension properties |
110
+ methodDictionary := behavior persistentMethodDictForEnv: 0 .
111
+ selector := compiledMethod selector.
112
+ methodDictionary at: selector put: compiledMethod.
113
+
114
+ protocolSymbol := protocolString asSymbol.
115
+ (behavior includesCategory: protocolSymbol)
116
+ ifFalse: [ behavior addCategory: protocolSymbol ].
117
+ behavior moveMethod: selector toCategory: protocolSymbol.
118
+
119
+ existing := methodRegistry at: compiledMethod ifAbsent: [ nil ].
120
+ existing
121
+ ifNotNil: [
122
+ self
123
+ error:
124
+ ' Internal error -- existing LoadedMethod found for extension compiled method.' ].
125
+ loadedMethod := RwGsLoadedSymbolDictMethod forMethod: compiledMethod.
126
+
127
+ methodRegistry at: compiledMethod put: loadedMethod.
128
+
129
+ loadedPackage := self packageRegistry
130
+ at: packageName
131
+ ifAbsent: [
132
+ self
133
+ error: ' Internal error -- attempt to add a method to a nonexistent package.' ].
134
+
135
+ loadedClassOrExtension := loadedPackage
136
+ loadedClassExtensionForClass: behavior
137
+ ifAbsent: [
138
+ self
139
+ error:
140
+ ' Internal error -- attempt to add a method to a package in which its class is neither defined nor extended.' ].
141
+ loadedClassOrExtension addLoadedMethod: loadedMethod
110
142
]
111
143
112
144
{ #category : ' class - patch api' }
@@ -155,7 +187,7 @@ RwGsPackageSymbolDictionary >> addNewCompiledMethod: compiledMethod for: behavio
155
187
error: ' Internal error -- attempt to add a method to a nonexistent package.' ].
156
188
157
189
loadedClassOrExtension := loadedPackage
158
- classOrExtensionForClassNamed : behavior theNonMetaClass name asString
190
+ loadedClassForClass : behavior
159
191
ifAbsent: [
160
192
self
161
193
error:
@@ -287,7 +319,7 @@ RwGsPackageSymbolDictionary >> deleteCompiledMethod: compiledMethod from: behavi
287
319
288
320
loadedPackage := loadedMethod loadedPackage.
289
321
loadedClassOrExtension := loadedPackage
290
- classOrExtensionForClassNamed : behavior theNonMetaClass name asString
322
+ classOrExtensionForClass : behavior
291
323
ifAbsent: [
292
324
self
293
325
error:
0 commit comments