fix generic inference with ref type