[Pharo-dev] renaming method propagation

Guillermo Polito guillermopolito at gmail.com
Mon Aug 5 16:13:18 EDT 2013


Now, why does ring answer true to isActive if the method does not exist any
more?


On Mon, Aug 5, 2013 at 10:03 PM, Stéphane Ducasse <stephane.ducasse at inria.fr
> wrote:

> Hi guys
>
> I found a problem with method renaming. The scenario is the following one:
>
>         - you have a message browser open with a list a methods (resulting
> from a sender/implementor).
>         - you rename a method and you get an error
>
> why because the message browser does not replace the currently changed
> method.
> and  the RGMethodDefinition that represented the renamed method defines
> the code like that
>
> MessageBrowser>>wrapItem: anItem
>         | s |
>
>         s :=String streamContents: [ :aStream |
>                 3 to: (cachedHierarchy at: anItem) size do: [:i | aStream
> << '    '].
>                 aStream
>                         << anItem methodClass name << ' ('.
>                 anItem isFromTrait
>                         ifTrue: [ aStream << anItem compiledMethod origin
> name; space ].
>                 aStream << (anItem category ifNil: ['']) <<')'].
>                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
>         ^ {s. anItem selector}.
>
> RGMethodDefinition>>compiledMethod
>         "Retrieves the compiled method of this definition if exists"
>
>         | rClass |
>         (rClass := self realClass) notNil
>                 ifTrue: [ (rClass includesSelector: self selector)
>                         ifTrue: [ ^rClass >> self selector ] ].
>         ^nil
>
> category
>
>         ^ self protocol
>
> protocol
>
>         self isActive
>                 ifTrue: [ ^ self compiledMethod  category ]].
>         self isHistorical
>                 ifTrue: [ ^ self protocolAtPointer ifNil:[ self
> compiledMethod ifNil:[ protocol ] ifNotNil:[ :cm| cm category ] ] ].
>         ^ protocol
>
> So I patched the protocol method as follows
>
> protocol
>
>         self isActive
>                 ifTrue: [ ^ self compiledMethod ifNil: [ ' '] ifNotNilDo:
> [ :cm | cm  category ]].
>                 "I hate this ifNil test, the problem is that when we
> rename a method, a method definition in a list may still refers to
>                 the old selector and the definition of compiled method is
> that case is not finding the associated method because it holds the
>                 old selector and not the one corresponding to the one
> defined in the class."
>         self isHistorical
>                 ifTrue: [ ^ self protocolAtPointer ifNil:[ self
> compiledMethod ifNil:[ protocol ] ifNotNil:[ :cm| cm category ] ] ].
>         ^ protocol
>
> I imagine that the best solution would be that the tools update their
> contents but I wanted to know your point of view.
>
> Stef
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pharo.org/pipermail/pharo-dev_lists.pharo.org/attachments/20130805/cdbaf22d/attachment-0002.html>


More information about the Pharo-dev mailing list