Hi list,
I'm currently trying to clean-up a macro I wrote to support @:native on var names in js :
I managed to make it work using a typedef / MacroType that generates an abstract using defineType.
Now I'd like to simplify the macro to a @:build macro on an abstract definition, such as this:
@:build(util.NativeMap.buildFields())
abstract Options({
@:native("some-option")
var someOption : String;
}){}
The build macro should automatically create the abstract constructor, and get/set properties to convert the field name from "someOption" to "some-option", pretty much like it does here :
My problem is, it seems impossible to create instance methods on abstract at macro time.
The compiler throws :
Cannot access this from a static function
My understanding is that the build macro is executed at a time when the abstract have already been converted to an "abstract implementation".
The methods declared directly normally in an abstract are indeed already transformed to static, 'this' being the first argument. These methods seem to be also tagged with an @:impl metadata.
So I tried to define the abstract methods this way in my macro, but without luck...
Any way, is this an actual bug, or is there an alternative way of building abstract using macros (besides declaring types using defineType) ?
Best,
Clément