Help us understand the problem. What is going on with this article?

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() 
    {
    }
}

(´・ω・`)

tail_y
Flashでゲームとか作ってます
http://sipo.jp/
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away