HaxeFoundation/haxe — pull request #2445 by Simn (2013-12-09 11:19:45+00:00)
Title: Add @:genericBuild (closes #1489)

This adds @:genericBuild macros, which are like normal @:build macros but run per-instance. This means that they have access to type parameters, at least explicit ones.

See here for an example of how to approximate the current @:generic behavior with this: https://gist.github.com/Simn/8ae509cc3824099c1567

This is implemented by keeping the AST version of the class fields in KGenericBuild, which is a basic requirement. Upon instance building, these class fields along with the class type and the type parameters are then added to the build infos and can be obtained from Context.getLocalType() and Context.getBuildFields().