Class type incompatible with generics

Hi all.

Just a small thing I encountered where I feel like it ought to be possible and I could be missing something. I had the following code:

static function main() {
dothing(MyGeneric<Float>);
}

static function dothing<T>(type : Class<T>) : Void {
trace(type);
}

I thought it might be possible to solve this by marking MyGeneric<T> using @:generic, but it still failed with the compiler complaining about dothing(MyGeneric<Float>) being an invalid expression.

Can this be done at all? Any help would be much appreciated :smile:

You need to insert Type.resolveClass in place of MyGeneric (without type param) because you get Class at runtime like this

macro function resolveClass(e:haxe.macro.Expr) {
var name = haxe.macro.ExprTools.toString(e);
var ret = macro Type.resolveClass($v{name});
trace(haxe.macro.ExprTools.toString(ret));
return ret;
}

class Main {
static function main() {
dothing(resolveClass(MyGeneric));
}
}