haxe
haxe copied to clipboard
Possible issue with function bind
Using haxe 4 rc3 and hashlink 1.9 Giving a basic class structure like
class Node
{
public function new()
{
}
public function addNode<T:Node>(node:T):T
{
return node;
}
}
class AnotherNode extends Node
{
}
The following code fails to compile with the error Don't know how to cast #Node to #AnotherNode
var s:Node = new Node();
s.addNode.bind(new AnotherNode());
This code compiles without issue on the flash/cpp targets.
If i changed the <T:Node> to just <T> it works fine, but then I can't enforce a base type for the call. Another option that works is to change it to
public addNode<T:Node>(node:Node):T
{
return cast node;
}
Should this issue be added to the haxe github?
This is actually a bug in the haxe compiler HL generation, should be fixed as it's not a platform limitation.