You should use `isgeneric` to check for a generic function. `env` is not always `()` for anonymous functions!