Search code examples
pharo

Pharo Metalink not works on #ifTrue: send node


When I add MetaLink to all send nodes in the following code, the Metalink on #ifTrue: not works:

aMethod
    10 = 11
        ifTrue: [ ^ 3 ]

code to add MetaLinks:

ast sendNodes do: [ :n | 
            n link: (MetaLink new
                        metaObject: [ :node | 
                            Transcript show: node asString; cr ];
                        arguments: #(node);
                        selector: #value:;
                        control: #before;
                        yourself) ]

Can anyone explain why this happens? How can I add a MetaLink on a #ifTrue: send?


Solution

  • Thanks to the comment from @ LeandroCaniglia, this is because of compile optimization.

    You can uncheck Inline If in Opal Compiler settings and recompile the method.

    After recompile, reinstall your Metalinks and you will see #ifTrue: as a message call.