There seems to be a bunch of weird restrictions regarding passing functions as arguments into build macros, this works fine:
@:build(Macro.test((s) -> true))
class Test1 {}
I can’t reference class functions:
@:build(Macro.test(TestFilter.filter))// EvalContext.RunTimeException(_, 0, _)
class Test2 {}
class TestFilter {
static public function filter(path:String):Bool
return true;
}
I can’t call trace
@:build(Macro.test(
(s) -> {
trace(s);// Unknown identifier: `trace
return s != "bar";
}
))
class Test3 {}
can’t even reference StringTools
@:build(Macro.test((s) -> StringTools.contains(s, "bar"))) // Uncaught exception Cannot call null
class Test4 {}
Is there any way around this?