Main.hx 474 B

12345678910111213141516171819202122232425
  1. #if !macro
  2. typedef Huh = GenericBuild<Int>;
  3. @:genericBuild(Main.GenericBuild.build())
  4. #end
  5. class GenericBuild<T> {
  6. #if macro
  7. static var counter = 0;
  8. static function build() {
  9. var name = 'Cls${counter++}';
  10. var ret = macro class $name {
  11. public function new() {}
  12. }
  13. haxe.macro.Context.defineType(ret);
  14. return haxe.macro.Context.getType(name);
  15. }
  16. #end
  17. }
  18. class Main {
  19. static function main() {
  20. #if !macro
  21. $type(Huh.new);
  22. #end
  23. }
  24. }