title: Calling an overloaded java generic method from scala
body: <p>I'm using Mockito to mock an object with a method which returns an un-parametrized ArrayList, and I cannot figure out how to get this to work</p>
  
  <p><strong>Method signature to mock</strong></p>
  
  <pre><code>public java.util.ArrayList getX()
  </code></pre>
  
  <p><strong>Test code</strong></p>
  
  <pre><code>var mockee = mock(classOf[Mockee])
  when(mockee.getX).thenReturn(Lists.newArrayList(x): ArrayList[_])
  </code></pre>
  
  <p>This actually compiles fine in IntelliJ, but at runtime throws:</p>
  
  <pre><code>[error] ....scala:89: overloaded method value thenReturn with alternatives:
  [error]   (java.util.ArrayList[?0],&lt;repeated...&gt;[java.util.ArrayList[?0]])org.mockito.stubbing.OngoingStubbing[java.util.ArrayList[?0]] &lt;and&gt;
  [error]   (java.util.ArrayList[?0])org.mockito.stubbing.OngoingStubbing[java.util.ArrayList[?0]]
  [error]  cannot be applied to (java.util.ArrayList[_$1])
  [error]       when(mockee.getX).thenReturn(Lists.newArrayList(x): ArrayList[_])
  </code></pre>