[Glass] RefactoringBrowser (RB) failing to correctly bind "self" in closures?

Mariano Martinez Peck via Glass glass at lists.gemtalksystems.com
Thu Nov 19 12:29:15 PST 2015


I forgot to said..the message node:

*(self lookupMatchFor: '`#oldSelector' in: aDictionary) *

Gets generated in:

RBPatternBlockNode >> constructLookupNodeFor: aString in: aRBBlockNode
| argumentNode |
argumentNode := RBLiteralNode value: aString.

^RBMessageNode
receiver:* (RBVariableNode named: 'self')*
selector: #lookupMatchFor:in:
arguments: (Array with: argumentNode with: aRBBlockNode arguments last)

On Thu, Nov 19, 2015 at 5:17 PM, Mariano Martinez Peck <
marianopeck at gmail.com> wrote:

> Hi guys,
>
> I have some code that uses RB and such code works correctly in Pharo but
> it fails in GemStone. It seems a problem with a closure which in Pharo
> "self" resolves to the real object while in GemStone resolves to nil.
>
> The way to reproduce it is:
>
> *| tree rewriter |*
> *tree := RBParser parseMethod: 'DoIt ^ [:proxy | proxy at: #oldSelector.
> ]'.*
> *rewriter := RBParseTreeRewriter new. *
> *rewriter *
> * replace: ('`#oldSelector `{:node | node value isSymbol and: [node value
> matchesRegex: ''.*oldSelector.*''] }')*
> * with: ('`{RBLiteralNode value: (`#oldSelector value copyReplaceAll:
> ''oldSelector'' with: ''newSelector'') asSymbol }').*
> *rewriter executeTree: tree. *
> *rewriter tree newSource*
> And the problem is the line:
>
> *with: ('`{RBLiteralNode value: (`#oldSelector value copyReplaceAll:
> ''oldSelector'' with: ''newSelector'') asSymbol }').*
>
> which gets translated to:
>
> *[ :aDictionary | RBLiteralNode  value:    ((self lookupMatchFor:
> '`#oldSelector' in: aDictionary) value      copyReplaceAll: 'oldSelector'
>     with: 'newSelector') asSymbol ]*
>
> And the self there fails.
>
> Any idea how this is expected to work?
>
> Thanks in advance
>
>
> --
> Mariano
> http://marianopeck.wordpress.com
>



-- 
Mariano
http://marianopeck.wordpress.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gemtalksystems.com/mailman/private/glass/attachments/20151119/faadbebf/attachment.html>


More information about the Glass mailing list