diff --git a/tests/misc/projects/Issue11545/Macro.hx b/tests/misc/projects/Issue11545/Macro.hx new file mode 100644 index 00000000000..e2ef32ec14b --- /dev/null +++ b/tests/misc/projects/Issue11545/Macro.hx @@ -0,0 +1,30 @@ +#if macro +import haxe.macro.Compiler; +import haxe.macro.Context; +import haxe.macro.Expr; + +class Macro { + public static function initMacro() { + Compiler.addGlobalMetadata("Main", "@:build(Macro.instrumentFields())", true, true, false); + } + + static function instrumentFields():Null> { + var fields:Array = Context.getBuildFields(); + for (field in fields) { + switch (field.kind) { + case FFun(f): + if (f.expr == null) { + continue; + } + switch (f.expr.expr) { + case EBlock(exprs): + exprs.unshift(macro trace($v{field.name})); + case _: + } + case _: + } + } + return fields; + } +} +#end diff --git a/tests/misc/projects/Issue11545/Main.hx b/tests/misc/projects/Issue11545/Main.hx new file mode 100644 index 00000000000..715e75f1b07 --- /dev/null +++ b/tests/misc/projects/Issue11545/Main.hx @@ -0,0 +1,12 @@ +class Main { + static function main() { + var name = new ImageName("abc"); + trace(name); + } +} + +abstract ImageName(String) { + public function new(name:String) { + this = name; + } +} diff --git a/tests/misc/projects/Issue11545/compile.hxml b/tests/misc/projects/Issue11545/compile.hxml new file mode 100644 index 00000000000..edb63433c3b --- /dev/null +++ b/tests/misc/projects/Issue11545/compile.hxml @@ -0,0 +1,2 @@ +--macro Macro.initMacro() +--run Main diff --git a/tests/misc/projects/Issue11545/compile.hxml.stdout b/tests/misc/projects/Issue11545/compile.hxml.stdout new file mode 100644 index 00000000000..91b293171ec --- /dev/null +++ b/tests/misc/projects/Issue11545/compile.hxml.stdout @@ -0,0 +1,3 @@ +Macro.hx:21: main +Macro.hx:21: _new +Main.hx:4: abc