upgrade – Stuck with a Magento override problem

Recently upgraded to Magento enterprise edition 2.3.5-p2, I have a problem that occurs with a specific module during compilation:

            Incompatible argument type: Required type: MagentoCatalogApiCategoryRepositoryInterface. Actual type: array; File: 

I know how to solve this specific problem injecting the following dependency: MagentoCatalogApiCategoryRepositoryInterface $categoryRepository.

My biggest problem is that I have tried to override the Block in a custom module inside app/code but then when I execute magento setup:di:compile throws the error again.

I need to do it without touching directly the module files because it’s inside a module on the vendor folder.

Anyone has any idea of how to solve this?