Need help understanding some Mox source code

Hi everyone! I’m trying to understand this piece of Mox source code.

I get the part of adding the behaviour attribute to the generated module, but why is the reference to the behaviour module included by itself :thinking:? Not seen this pattern before. I guess the clue is in the function name, but I wanted to be sure.

Yep, super strange that it isn’t just unquote(behaviour)

If I had to guess it might be an aliasing thing, but that still doesn’t make sense to me.

1 Like

module_info might trigger some cache busting or otherwise refreshing of all implementations of the behaviour.

1 Like

Digging through the source history, that generated call to module_info predates the use of @behaviour and was originally introduced to ensure that the generated module recompiled at the correct times:

A generated @behaviour line was added later, and without disturbing the existing line:

2 Likes

Lol that’s my pr!