HaxeFoundation / HaxeFoundation/haxe
RTTI wrong for class that contains type alias
- Dominant language
- Haxe
- Stars
- 6.9k
- Forks
- 715
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 11
Description
I am trying to build a routine that builds class instances from dynamic data, and am trying to use rtti to validate reconstructed types. I ran into an issue when processing the rtti for a class that has a variable defined with a type alias.
Here's an example:
foo/Foo.hx
```
package foo;
@:rtti class Foo {}
```
bar/Bar.hx
```
package bar;
typedef Bar = foo.Foo;
```
Main.hx
```
import bar.Bar;
@:rtti class Main {
var _bar:Bar;
public static function main() {}
}
```
Compiled with `haxe -cp . --js app.js --main Main.hx`
If you look at the generated app.js, the rtti string for Main references bar.Bar which does not exist in the generated javascript, and there doesn't appear to be anything in the generated js that would relate bar.Bar to foo.Foo (i.e. I tried looking at Type and other Rtti methods, but it looks like this information is lost). I've also tried annotating the typedef with @:rtti but that appears to be a no-op.
My guess is that rtti should store some information about the actual type (not just the alias), or that information should be accessible via a separate relation/call.
Contributor guide
Assessment
This issue has not been assessed yet.