So if anyone should read this question in the future, I finally found out that the problem was to specify properly where the eval
happens (and yes you actually have to use eval
here because the emitted code has to be from A not B)
Anyway so calling parentmodule(T).eval
solves the problem, it took me some time to find it but it works perfectly for my use case