title: Compile-time error using List.addAll to add a List<? extends BaseClass> to another one
body: <p>In this code, the last line (<code>list1.addAll(list2);</code>) generates the compile-time error</p>
  
  <blockquote>
    <p>The method addAll(Collection&lt; ? extends capture#3-of ? extends BaseClass>) in the type List&lt; capture#3-of ? extends BaseClass> is not applicable for the arguments (List&lt; capture#4-of ? extends BaseClass>)</p>
  </blockquote>
  
  <p>I do realize that if this was allowed it would be possible to add to the same list instances of different classes. However I don't know what's the right way to go about this.</p>
  
  <p>My <code>getList()</code> method needs to return subclasses of <code>BaseClass</code>, I cannot change that requirement.</p>
  
  <p>I have these two lists, declared in the same way and containing the same type of objects, and I need to add one into the other one.
  Any thoughts about this would be appreciated.</p>
  
  <p><strong>BaseClass.java</strong>:</p>
  
  <pre><code>package main;
  
  public class BaseClass {}
  </code></pre>
  
  <p><strong>Main.java</strong>:</p>
  
  <pre><code>package main;
  
  import java.util.ArrayList;
  import java.util.List;
  
  public class Main {
  
      private static List&lt;? extends BaseClass&gt; getList() {
  
          return new ArrayList&lt;&gt;();
      }
  
      public static void main(String[] args) {
  
          List&lt;? extends BaseClass&gt; list1 = getList();
  
          List&lt;? extends BaseClass&gt; list2 = getList();
  
          list1.addAll(list2); // Compile-time error: "The method addAll(Collection&lt;? extends capture#3-of ? extends BaseClass&gt;) in the type List&lt;capture#3-of ? extends BaseClass&gt; is not applicable for the arguments (List&lt;capture#4-of ? extends BaseClass&gt;)".
      }
  
  }
  </code></pre>