Add type inference for generic classes