Yes, I that is what I tried initially but the error was due to that static if.
Not sure why but static if (is(T : A)) { ... } static assert(0, "error"); doesn't work as the assert is called no matter what. Initially I forgot to return the value after changing the code but that doesn't matter. Had to change it to static if (is(T : A)) { ... return ...; } else static assert(0, "error"); return null; I guess because return is not "static" in some sense.