haxe
haxe copied to clipboard
Can't cast to a @:generic type parameter
trafficstars
this forum post got me thinking about this
This looks like it should work, since C is known at compile-time:
@:generic function doCast<C>(v:Any, c:Class<C>):C {
return cast(v, C);
}
Currently, it fails with Can't cast to a type parameter, just like without @:generic.
I just had this issue. In general, @:generic type parameters don't work like I'd expect them to, only specializing at compile-time for types it's actually used for (like C++)