title: how to unit test code that should cause compile error
body: <p>I have a class that take a ArrayList as parameter:</p>
  
  <pre><code>public class Foo {
      private ArrayList&lt;Bar&gt; bars;
  
      public Foo(ArrayList barList) {
          bars = barList;
      }
  }
  </code></pre>
  
  <p>there is a bug that I can pass any ArrayList into the constructor:</p>
  
  <pre><code>// should compile error with this line
  Foo foo = new Foo(new ArrayList&lt;String&gt;());
  </code></pre>
  
  <p>the problem is if I add this case to test suite, when the bug fixed, I can not compile it.
  is there anyway to test this case?</p>