为什么重写此核心文件“Magento \ Quote \ Model \ ShippingMethodManagement.php”会导致错误

i wrote a simple module to override this core Model class, but on frontend it shows this error message:

"Fatal error: Uncaught TypeError: Argument 3 passed to Magento\Quote\Model\Quote\ShippingAssignment\ShippingProcessor::__construct() must be an instance of Magento\Quote\Model\ShippingMethodManagement, instance of shipping\module\Model\ShippingMethodManagement\Interceptor ....."

HERE IS MY 'di.xml' file content:

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="Magento\Quote\Model\ShippingMethodManagement" type="shipping\module\Model\ShippingMethodManagement" />
</config>

You Need To Do :-

php bin/magento s:up

And Clean Cache

You need to run below commands after ensuring full permission:

chmod -R 777 var generated
php bin/magento setup:di:compile
php bin/magento cache:flush

If error still persist, check if you are in developer mode by this command:

php bin/magento deploy:mode:show

set in developer mode :

php bin/magento deploy:mode:set developer

after setting to developer mode, remove var and generated folder,

rm -rf var generated

then flush cache :

php bin/magento cache:flush
chmod -R 777 var generated

Extend your class using the core path of the file as given below.

In **shipping\module\Model**

class ShippingMethodManagement extends 
Magento\Quote\Model\ShippingMethodManagement
{
   //You can write your custom functionality here
}

Don't forget to run the following commands after the change.

chmod -R 777 var generated
php bin/magento setup:di:compile
php bin/magento cache:flush

After added new Argument in constructor, need to re-created interpreter.So run di :compile command

php bin/magento setup:di:compile