title: mockito-kotlin whenever arguments - Parameter specified as non-null is null
body: <p>For testing I wrote a wrapper for <code>ViewModelProviders.of(...).get(...)</code> so that I can supply a mock:</p>
  
  <pre><code>class MyViewModelProvider {
      fun &lt;T : ViewModel&gt; get(scope: Fragment, type: Class&lt;T&gt;) : T {
          return ViewModelProviders.of(scope).get(type)
      }
  
      ...
  }
  </code></pre>
  
  <p>And then in my test: </p>
  
  <p>Dagger TestModule:</p>
  
  <pre><code>import com.nhaarman.mockito_kotlin.mock
  
  ...
  
  fun provideMyViewModelProvider(): MyViewModelProvider {
          return mock()
  }
  </code></pre>
  
  <p>And in my test class:</p>
  
  <pre><code>import com.nhaarman.mockito_kotlin.any
  import com.nhaarman.mockito_kotlin.anyOrNull
  import com.nhaarman.mockito_kotlin.whenever
  ...
  @Inject
  lateinit var mockViewModelProvider: MyViewModelProvider
  ...
  val mockViewModel = mock&lt;MyViewModel&gt;()
  
  whenever(mockViewModelProvider.get(any&lt;Fragment&gt;(), any&lt;Class&lt;ViewModel&gt;&gt;())).thenReturn(mockViewModel)
  ...
  </code></pre>
  
  <p>However on the line with <code>whenever</code> I get the error:</p>
  
  <pre><code>java.lang.IllegalArgumentException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull, parameter scope
  </code></pre>
  
  <p>I've tried a couple things: </p>
  
  <ol>
  <li><p>Swapping <code>any&lt;Fragment&gt;(), any&lt;Class&lt;ViewModel&gt;&gt;())</code> with <code>anyOrNull&lt;Fragment&gt;(), anyOrNull&lt;Class&lt;ViewModel&gt;&gt;()</code> --> still get the same error</p></li>
  <li><p>Tried using concrete references <code>whenever(mockViewModelProvider.get(myFragment, MyViewModel::class.java)).thenReturn(mockViewModel)</code> --> Calls actual method instead of mock</p></li>
  </ol>
  
  <p>Not sure what I'm doing wrong...</p>