haxe icon indicating copy to clipboard operation
haxe copied to clipboard

Can't cast to a @:generic type parameter

Open nadako opened this issue 5 years ago • 1 comments
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.

nadako avatar Apr 02 '20 14:04 nadako

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++)

thomasjwebb avatar Aug 26 '22 17:08 thomasjwebb