<p dir="auto">The current implementation of autowiring seems to force unnecessary coupling and to be instable in case of change in a vendor's service implementation.</p>
<p dir="auto">Example 1:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="interface IA
interface IB extends IA
*service* class C implemets IB"><pre class="notranslate"><code class="notranslate">interface IA
interface IB extends IA
*service* class C implemets IB
</code></pre></div>
<p dir="auto">I can autowire using the type hint <code class="notranslate">IB</code>, but not <code class="notranslate">IA</code>.</p>
<p dir="auto">Example 2:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="interface I
class CA implements I
*service* class CB extends CA"><pre class="notranslate"><code class="notranslate">interface I
class CA implements I
*service* class CB extends CA
</code></pre></div>
<p dir="auto">I cannot type hint on <code class="notranslate">I</code>.</p>
<p dir="auto">This means, autowiring would break if an intermediary interface or an abstract class were added. Nothing in the documentation (<a href="http://symfony.com/doc/current/components/dependency_injection/autowiring.html" rel="nofollow">http://symfony.com/doc/current/components/dependency_injection/autowiring.html</a>) mentions this limitation and it seems highly counter-intuitive.</p>
<p dir="auto">If you agree this should be addressed, I am ready to provide a PR to fix this.</p>
<p dir="auto">With a fresh 4.1.1 install, I override the framework's router:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="namespace App\Service;
use Symfony\Bundle\FrameworkBundle\Routing\Router;
class AdminRouter extends Router
{
}"><pre class="notranslate"><code class="notranslate">namespace App\Service;
use Symfony\Bundle\FrameworkBundle\Routing\Router;
class AdminRouter extends Router
{
}
</code></pre></div>
<p dir="auto">And make a service with:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="App\Service\AdminRouter:
    arguments:
        $resource: 'resource'
        $options: []"><pre class="notranslate"><code class="notranslate">App\Service\AdminRouter:
    arguments:
        $resource: 'resource'
        $options: []
</code></pre></div>
<p dir="auto">Which generates a rather ominous error message:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="The service &quot;.service_locator.G69Xsbl.App\Service\AdminRouter&quot; 
has a dependency on a non-existent service &quot;Symfony\Component\Config\Loader\LoaderInterface&quot;."><pre class="notranslate"><code class="notranslate">The service ".service_locator.G69Xsbl.App\Service\AdminRouter" 
has a dependency on a non-existent service "Symfony\Component\Config\Loader\LoaderInterface".
</code></pre></div>
<p dir="auto">LoaderInterface?  Where the heck does that come from?  Looking at the framework's router:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="# Symfony\Bundle\FrameworkBundle\Routing\Router;
public function __construct(
    ContainerInterface $container, 
    $resource, 
    array $options = array(), 
    RequestContext $context = null, 
    ContainerInterface $parameters = null, 
    LoggerInterface $logger = null)
{"><pre class="notranslate"><code class="notranslate"># Symfony\Bundle\FrameworkBundle\Routing\Router;
public function __construct(
    ContainerInterface $container, 
    $resource, 
    array $options = array(), 
    RequestContext $context = null, 
    ContainerInterface $parameters = null, 
    LoggerInterface $logger = null)
{
</code></pre></div>
<p dir="auto">Notice the two ContainerInterfaces.  Someone got a bit "clever" with the parameters injection.</p>
<p dir="auto">Changing the service definition fixes the problem:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="App\Service\AdminRouter:
    arguments:
        $container: '@service_container'
        $parameters: '@service_container'
        $resource: 'resource'
        $options: []"><pre class="notranslate"><code class="notranslate">App\Service\AdminRouter:
    arguments:
        $container: '@service_container'
        $parameters: '@service_container'
        $resource: 'resource'
        $options: []
</code></pre></div>
<p dir="auto">Is this a bug or some sort of feature?  Obviously injecting the same type twice is a fairly rare thing.  If it is a bug then is it even worth fixing?</p>