[Pharo-dev] new bug in RPackage
estebanlm at gmail.com
Wed Oct 2 15:45:29 EDT 2013
I'm so tired of RPackage... :(
On Oct 2, 2013, at 9:36 PM, Stéphane Ducasse <stephane.ducasse at inria.fr> wrote:
> In fact what is intriguing is that
> RPackageOrganizer default
> packageNamed: 'Refactoring-Core'
> in the image used to generate the configuration
> classExtensionSelectors is correct defined
> a Dictionary(#ClassTrait->a Set(#soleInstance) #TClassDescription->a Set(#whichSelectorsReallyRead:) )
> So either the package is wrongly saved but this is not the case.
> Or while reloading it the logic is wrong. May be it should not raise systemMethodRecategorizedActionFrom:
> because it may be not be a recatogiration (or may be it was a override).
> On Oct 2, 2013, at 9:28 PM, Stéphane Ducasse <Stephane.Ducasse at inria.fr> wrote:
>> tomorrow I can show you the bug I found.
>> during the test of the correct reloading of RB
>> (ConfigurationOfRefactoring project version: #stable) load
>> in my noNautilus and no RB I got
>> systemMethodRecategorizedActionFrom: ann
>> "a protocol has been renamed
>> a method has been removed. // WILL BE TREATED WITH SystemMethodRemovedAnnouncement
>> a method has been moved to another category
>> -maybe from the classic category to an extending package
>> -maybe from an extending package to another extending package
>> -maybe from an extending package to a classic category
>> - maybe from a classic category to another classic category"
>> | oldProtocol newProtocol method methodPackage destinationPackage |
>> oldProtocol := ann oldProtocol.
>> "old protocol might be nil:"
>> oldProtocol asString ifNil: [oldProtocol := ''].
>> newProtocol := ann newProtocol.
>> method := ann methodRecategorized.
>> "1). See compiledMethod >> packageFromOrganizer:"
>> "we have to pay attention that this announcement can come from TraitDescription>>updateOrganizationSelector:oldCategory:newCategory: . In this context, it can happen that the method referenced by the event is nil. In this case I think we should change nothing"
>> method isNil ifFalse: [
>> "If the method origin is not the one of the event, we do not care about that method"
>> method origin = ann methodClass ifFalse: [^ self].
>> methodPackage := method packageFromOrganizer: self.
>> "if newProtocol is nil, it means that we are in a 'methodRemoved' case. Nothing should be modified (all the work will be done when catching methodRemovedAnnouncement) "
>> newProtocol isNil ifTrue: [^self].
>> "it can happen that oldProtocol is Nil. in this case we should do nothing"
>> oldProtocol ifNil: [^ self].
>> "maybe the category has changed"
>> newProtocol asLowercase = oldProtocol asLowercase
>> ifFalse: [
>> "according the extension specified is valid or not, the method will be defined as an extension of an external package or in the class parent package"
>> destinationPackage := (self hasPackageForProtocol: newProtocol inClass: method methodClass)
>> ifTrue: [ self packageForProtocol: newProtocol inClass: method methodClass ]
>> ifFalse: [
>> (newProtocol beginsWith: '*')
>> ifTrue: [ self ensureExistAndRegisterPackageNamed: newProtocol allButFirst capitalized ]
>> ifFalse: [ method methodClass package ] ].
>> methodPackage := (self hasPackageForProtocol: oldProtocol inClass: method methodClass)
>> ifTrue: [ self packageForProtocol: oldProtocol inClass: method methodClass ]
>> ifFalse: [ method methodClass package ].
>> "then, we will remove the method from the method package, and add it to the destination package (we check before that the source package and the destination package are different)."
>> methodPackage = destinationPackage
>> ifFalse: [
>> (methodPackage methods includes: method)
>> ifTrue: [ methodPackage removeMethod: method ].
>> where method was ClassTrait>>#soleInstance and apparently it does not exit raising an error
>> classDefinitionSelectors in RPackage is
>> a Set(#instanceVariableNames: #classTrait #copy #adoptInstance:from: #compile:classified:withStamp:notifying:logSource: #baseTrait #name #baseTrait: #isClassTrait #definition #classTrait: #initializeWithBaseTrait: #new #isBaseTrait)
>> classExtensionSelectors is Set new
>> and after investigation:
>> soleInstance on ClassTrait is defined as an extension on *refactoring-core
>> destinationPackage addMethod: method.
>> SystemAnnouncer uniqueInstance
>> methodRepackaged: method
>> from: methodPackage
>> to: destinationPackage.
More information about the Pharo-dev