checks that the generic parameter is a class (and not a type variable) before casting it to a class