Hej
First time I run in “cyclical reference” when building types using macros, I fight with that for 2 days now.
Error was even hard to detect since compiler doesn’t throw anything saying like “you get a partially built type”, but gives me the type without fields : Try Haxe !
@:build(Macro.build())
class A {
var b:B;
}
@:build(Macro.build())
class B {
var a:A;
}
So I suppose compiler can’t say if/when a type is fully built, I have to check if what I try to access is filled right ?
Then, I try to avoid that cyclical redundancy using Context.onAfterTyping
: I try to define a new type using Context.defineType
and excluding the original one, but I can’t exclude it, it tells me “Type name A is redefined from module Test” Try Haxe !
In fact doing that I just want to kind of relaunch the build macro a second time in order to this time get the missing fields of the foreign type, but I even don’t know if I’ll succed doing that.
Can anyone give me advice on how to proceed here please ? First, why the class can’t be excluded, and then globally is it a good thing to avoid cyclical redundancy ?
Thanks for reading,