'From Pharo2.0a of ''18 April 2012'' [Latest update: #20535] on 11 February 2013 at 2:22:35 pm'! SystemAnnouncement subclass: #MethodRemoved instanceVariableNames: 'methodRemoved protocol selector methodClass methodOrigin ' classVariableNames: '' poolDictionaries: '' category: 'System-Announcements'! !TClassAndTraitDescription methodsFor: 'accessing method dictionary' stamp: 'MartinDias 2/11/2013 14:08'! removeSelector: selector "Remove the message whose selector is given from the method dictionary of the receiver, if it is there. Answer nil otherwise." | priorMethod priorProtocol origin | priorMethod := self compiledMethodAt: selector ifAbsent: [^ nil]. origin := priorMethod origin. priorProtocol := self whichCategoryIncludesSelector: selector. super removeSelector: selector. SystemAnnouncer uniqueInstance suspendAllWhile: [self updateOrganizationSelector: selector oldCategory: priorProtocol newCategory: nil]. SystemAnnouncer uniqueInstance methodRemoved: priorMethod selector: selector inProtocol: priorProtocol class: self origin: origin.! ! !ClassDescription methodsFor: 'accessing method dictionary' stamp: 'MartinDias 2/11/2013 14:12'! removeSelector: selector "Remove the message whose selector is given from the method dictionary of the receiver, if it is there. Answer nil otherwise." | priorMethod priorProtocol origin | priorMethod := self compiledMethodAt: selector ifAbsent: [^ nil]. origin := priorMethod origin. priorProtocol := self whichCategoryIncludesSelector: selector. super removeSelector: selector. SystemAnnouncer uniqueInstance suspendAllWhile: [self updateOrganizationSelector: selector oldCategory: priorProtocol newCategory: nil]. SystemAnnouncer uniqueInstance methodRemoved: priorMethod selector: selector inProtocol: priorProtocol class: self origin: origin.! ! !MethodRemoved methodsFor: 'testing' stamp: 'MartinDias 2/11/2013 14:09'! isProvidedByATrait ^ self methodOrigin ~= self methodClass ! ! !MethodRemoved methodsFor: 'accessing' stamp: 'MartinDias 2/11/2013 14:09'! methodOrigin ^ methodOrigin! ! !MethodRemoved methodsFor: 'accessing' stamp: 'MartinDias 2/11/2013 14:09'! methodOrigin: anObject methodOrigin := anObject ! ! !MethodRemoved class methodsFor: 'instance creation' stamp: 'MartinDias 2/11/2013 14:10'! methodRemoved: aCompiledMethod selector: aSelector protocol: aProtocol class: aClass origin: anOrigin ^self new methodRemoved: aCompiledMethod; selector: aSelector; protocol: aProtocol; methodClass: aClass; methodOrigin: anOrigin; yourself! ! !RPackageOrganizer methodsFor: '*RPackage-SystemIntegration' stamp: 'MartinDias 2/11/2013 14:12'! systemMethodRemovedActionFrom: ann | method methodPackage | method := ann methodAffected. "If the method is provided by a trait, we do not care about it" ann isProvidedByATrait ifTrue: [^ self]. ann methodClass isMeta ifFalse: [ methodPackage := self packageDefiningOrExtendingSelector: ann selector inClassNamed: ann methodClass theNonMetaClass originalName. methodPackage removeSelector: ann selector ofClassName: ann methodClass theNonMetaClass originalName. ] ifTrue: [ methodPackage := self packageDefiningOrExtendingSelector: ann selector inMetaclassNamed: ann methodClass theNonMetaClass originalName. methodPackage removeSelector: ann selector ofMetaclassName: ann methodClass theNonMetaClass originalName. ]! ! !RPackageTraitSynchronisationTest methodsFor: 'tests - operations on methods' stamp: 'MartinDias 2/11/2013 14:21'! testRemoveTraitMethodOverridenByClassDoesRemoveMethodFromClassPackage "test that when we remove a class method overriding the one from a trait, the method is removed from the class package" |XPackage YPackage class trait| self addXCategory. self addYCategory. XPackage := self organizer packageNamed: #XXXXX. YPackage := self organizer packageNamed: #YYYYY. class := self createNewClassNamed: 'NewClass' inCategory: 'XXXXX'. trait := self createNewTraitNamed: 'NewTrait' inCategory: 'YYYYY'. self createMethodNamed: 'stubMethod' inClass: trait inCategory: 'classic protocol'. class setTraitComposition: trait asTraitComposition. self createMethodNamed: 'stubMethod' inClass: class inCategory: 'classic protocol'. class removeSelector: #stubMethod. self deny: (XPackage includesDefinedSelector: #stubMethod ofClass: class). ! ! !SystemAnnouncer methodsFor: 'triggering' stamp: 'MartinDias 2/11/2013 14:08'! methodRemoved: aMethod ^ self methodRemoved: aMethod selector: aMethod selector class: aMethod methodClass origin: aMethod origin! ! !SystemAnnouncer methodsFor: 'triggering' stamp: 'MartinDias 2/11/2013 14:07'! methodRemoved: aMethod selector: aSymbol class: aClass origin: anOrigin "A method with the given selector was removed from the class." self announce: (MethodRemoved methodRemoved: aMethod selector: aSymbol protocol: nil class: aClass origin: anOrigin)! ! !SystemAnnouncer methodsFor: 'triggering' stamp: 'MartinDias 2/11/2013 14:07'! methodRemoved: aMethod selector: aSymbol inProtocol: protocol class: aClass origin: anOrigin "A method with the given selector was removed from the class." self announce: (MethodRemoved methodRemoved: aMethod selector: aSymbol protocol: protocol class: aClass origin: anOrigin)! ! SystemAnnouncer removeSelector: #methodRemoved:selector:class:! SystemAnnouncer removeSelector: #methodRemoved:selector:inProtocol:class:! MethodRemoved class removeSelector: #methodRemoved:selector:protocol:class:! SystemAnnouncement subclass: #MethodRemoved instanceVariableNames: 'methodRemoved protocol selector methodClass methodOrigin' classVariableNames: '' poolDictionaries: '' category: 'System-Announcements'! !MethodRemoved reorganize! ('testing' isProvidedByATrait) ('accessing' methodAffected methodClass methodClass: methodOrigin methodOrigin: methodRemoved methodRemoved: protocol protocol: selector selector:) !