Edited at

GenericStackをTypeParameter混じりのstaticな関数として扱うと、関数参照を渡せなくなる

More than 5 years have passed since last update.


Test.hx

import haxe.ds.GenericStack;

class Test
{
var arrayFunctionHolder:Array<String> -> Void;
var stackFunctionHolder:GenericStack<String> -> Void;

static public function arrayFunction<T>(param:Array<T>):Void
{
}

static public function stackFunction<T>(param:GenericStack<T>):Void
{
}

static public function stackFunction2(param:GenericStack<String>):Void
{
}

public function new()
{
arrayFunctionHolder = arrayFunction; // ok
// stackFunctionHolder = stackFunction; // error...
// stackFunctionHolder = stackFunction<String>; // error...
// stackFunction<String>(new GenericStack<String>()); // error...
stackFunction2(new GenericStack<String>()); // ok
var hoge:Hoge<String> = new Hoge(stackFunction); // ok...
}
}
class Hoge<T>
{
public var hoge2:Hoge2<T>;
public function new(func:GenericStack<Hoge2<T>> -> Void)
{
hoge2 = new Hoge2<T>();
}
}
class Hoge2<T>
{
public var stackFunctionHolder:GenericStack<T>;
public function new()
{
}
}


(´・ω・`)