Ok I see what you're trying to do,
first a quick clarificaiton on PosInfo,
it's a very special type that cannot be instanciated but if present in a method signature will be filled at compile time :
var pos = new haxe.PosInfos() ; // build failed:haxe.PosInfos cannot be constructed
////
class Test {
static function main(){
Tracer.customTrace("Hello World!") ; // Test.hx:3: Hello World!
}
}
class Tracer {
public static function customTrace(s:Dynamic, ?p:haxe.PosInfos)
{
js.Lib.alert( p.fileName +':'+ p.lineNumber +": "+ s ) ;
}
}
As you can see we use ?p:haxe.PosInfos in the method signature and call customTrace with only the first parameter,
now with every other type that would result in p being null, but for PosInfos the compiler will instead create an instance of PosInfos containing the position where the function was called
Of course if we were to pass a PosInfo instance (created from a higher call function) it wouldn't be overriden
The main use for PosInfos is for trace, you can easily setup your own trace, for a fancy/customized trace or compatibility with other loggers (MonsterDebugger, remote logger, etc...) by affecting your customTrace function to haxe.Log.trace
haxe.Log.trace = Tracer.customTrace ;
trace("plop") ; // will show an alert "File.hx:X: plop"
Going back to your problem I think your approach is right, and I don't really know why the compiler doesn't realize T is a function but I'd rather think it as a bug/unattended behavior,
Dima's solution is ok, the Haxe world revolves around those little hacks, you could also use this :
public function Call()
{
untyped delegate("bar") ;
}
Cheers,
Renaud