title: Why class want instance, but i don't use it?
body: <p>I have 2 interfaces:</p>
  
  <pre><code>interface IAvsBus(input bit clk);
      bit [15:0] wraddr, rdaddr;
      bit [31:0] wrdata;
      logic [31:0] rddata;
      bit write, read;
  endinterface
  
  interface ISpi();
      logic sclk, csn, mosi, miso;
  endinterface
  </code></pre>
  
  <p>And 2 classes with interfaces:</p>
  
  <pre><code>class AvsBus;
      virtual IAvsBus bus;
  
      function new(virtual IAvsBus bus);
          this.bus = bus;
      endfunction
  
      task automatic Write(int unsigned addr, int unsigned data);
  ...
      endtask
  
      task automatic Read(int unsigned addr, output int unsigned data);
  ...
      endtask
  endclass :AvsBus
  
  class SpiBus;
      virtual ISpi spi;
  
      function new(virtual ISpi spi);
          this.spi = spi;
          this.spi.sclk = 0;
          this.spi.csn = 1;
          this.spi.mosi = 1;
      endfunction
  
      task WriteSingle(input shortint addr, input int data, output bit result);
  ...
      endtask
  
      task ReadSingle(shortint unsigned addr, output int unsigned read_data, output bit result);
  ...
      endtask
  endclass :SpiBus
  </code></pre>
  
  <p>And common class which uses one of them in testbench:</p>
  
  <pre><code>class Task;
  ...
      task Write(ref AvsBus bus);
  ...
      endtask
  
      task SpiWrite(ref SpiBus spi);
  ...
      endtask
  endclass :Task
  </code></pre>
  
  <p>If I comment out the unused class and unused task from the common class, then all work. It does not work if both exist. ModelSim throws an error, such as:  </p>
  
  <blockquote>
    <p>Virtual interface resolution cannot find a matching instance for 'virtual IAvsBus'</p>
  </blockquote>