hxcpp icon indicating copy to clipboard operation
hxcpp copied to clipboard

@:generic ignores @:unreflective

Open acarioni opened this issue 1 year ago • 5 comments

When a Haxe class is annotated with both @:generic and @:unreflective, the corresponding C++ class still retains the reflection machinery.

For example, compiling the following code with these annotations generates a class named MyClass_Int.cpp, which contains declarations such as HX_DEFINE_DYNAMIC_FUNC0(MyClass_Int_obj, get, return).

I am using Haxe 4.3.4 (but Haxe 4.3.3 exhibits the same behaviour).

@:generic
@:unreflective
class MyClass<T> {
  var _v: T;
  public function new(v: T) _v = v;
  public function get() return _v;
}

class Main {
  static function main() {
    trace(new MyClass(1).get());
  }
}

acarioni avatar Apr 23 '24 09:04 acarioni

Fixed by the linked commit, but I don't know how to test this robustly.

Simn avatar Apr 23 '24 09:04 Simn

Thanks. I'll try the nightly build.

acarioni avatar Apr 23 '24 09:04 acarioni

The patch seems to work.

acarioni avatar Apr 24 '24 12:04 acarioni

Is it possible to backport the patch on branch 4.3.x?

acarioni avatar Apr 24 '24 12:04 acarioni

Yeah @kLabz

Simn avatar Apr 24 '24 12:04 Simn