Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
A method installed by an Attribute object during compile time doesn't preserve it's closure. #2255
This report stems from a stackoverflow question. In short, if a role applied to an Attribute object which is being composed into a role installs a method on that role the method loses its closure causing Cannot invoke this object (REPR: Null; VMNull) error message during run time when the method is called. The problem occurs only if class and roles it is consuming are defined in different files; the class must consume one role directly whereas that role
Steps to Reproduce
Files in the archive demonstrate the problem.
Note that injected methods work for a class. Also, methods not using closure or installed by a role applied to
It is doesn't look like intended behavior. Taking the
The problem also seem to be macOS/darwin related because testing on Linux Mint 19 went ok, all variants of the attached scripts are working as expected.
Further investigation into the problem reveals that what happens here is that a closure gets lost upon serialization or deserialization of the modules. In the attached example methods added by the code in
A workaround is to use 'no precompilation
Another workaround is to use