HaxeFoundation / HaxeFoundation/haxe
Can't cast to a @:generic type parameter
Open
feature-generic
- Dominant language
- Haxe
- Stars
- 6.9k
- Forks
- 715
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 11
Description
> [this forum post](https://community.haxe.org/t/working-with-generics-entities-and-components/2331) got me thinking about this
This looks like it should work, since `C` is known at compile-time:
```haxe
@:generic function doCast(v:Any, c:Class):C {
return cast(v, C);
}
```
Currently, it fails with `Can't cast to a type parameter`, just like without `@:generic`.
Contributor guide
Assessment
This issue has not been assessed yet.