title: Kotlin - IllegalArgumentException in overridden method
body: <p>In Kotlin I'm overriding this two Google Sign-In functions:</p>
  
  <pre><code>override fun onConnectionFailed(result: ConnectionResult) {
          if (result.hasResolution()) {
              try {
                  result.startResolutionForResult(this, RESOLVE_CONNECTION_REQUEST_CODE)
              } catch (e: IntentSender.SendIntentException) {
                  // Unable to resolve, message user appropriately
              }
  
          } else {
              val gaa = GoogleApiAvailability.getInstance()
              gaa.getErrorDialog(this, result.errorCode, 0)
          }
      }
  
      override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent) {
          when (requestCode) {
              RESOLVE_CONNECTION_REQUEST_CODE -&gt; if (resultCode == Activity.RESULT_OK) {
                  mGoogleApiClient!!.connect()
              }
          }
      }
  </code></pre>
  
  <p>to check if the connection to google fails.</p>
  
  <p>The problem is that sometimes, when I dismiss the dialog containing user accounts, which pop-up when the activity is launched</p>
  
  <p>Like this one:</p>
  
  <p><a href="https://i.stack.imgur.com/DGM2i.png" rel="noreferrer"><img src="https://i.stack.imgur.com/DGM2i.png" alt="dialog"></a></p>
  
  <p>I'm getting an <code>IllegalArgumentException</code> with the following logcat</p>
  
  <blockquote>
    <p>E/AndroidRuntime: FATAL EXCEPTION: main
                      Process: com.dancam.subscriptions, PID: 6346
                      java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=6783, result=0, data=null} to activity {com.dancam.subscriptions/com.dancam.subscriptions.ActiveSubscriptions.Subscriptions_main}: java.lang.IllegalArgumentException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull, parameter data
                          at android.app.ActivityThread.deliverResults(ActivityThread.java:4126)
                          at android.app.ActivityThread.handleSendResult(ActivityThread.java:4169)
                          at android.app.ActivityThread.-wrap20(ActivityThread.java)
                          at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1552)
                          at android.os.Handler.dispatchMessage(Handler.java:102)
                          at android.os.Looper.loop(Looper.java:154)
                          at android.app.ActivityThread.main(ActivityThread.java:6186)
                          at java.lang.reflect.Method.invoke(Native Method)
                          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889)
                          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)
                       Caused by: java.lang.IllegalArgumentException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull, parameter data
                          at com.dancam.subscriptions.ActiveSubscriptions.Subscriptions_main.onActivityResult(Subscriptions_main.kt:0)
                          at android.app.Activity.dispatchActivityResult(Activity.java:6937)
                          at android.app.ActivityThread.deliverResults(ActivityThread.java:4122)
                          at android.app.ActivityThread.handleSendResult(ActivityThread.java:4169) 
                          at android.app.ActivityThread.-wrap20(ActivityThread.java) 
                          at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1552) 
                          at android.os.Handler.dispatchMessage(Handler.java:102) 
                          at android.os.Looper.loop(Looper.java:154) 
                          at android.app.ActivityThread.main(ActivityThread.java:6186) 
                          at java.lang.reflect.Method.invoke(Native Method) 
                          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889) 
                          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779) </p>
  </blockquote>
  
  <p>that points to the <code>onActivityResult</code> function.</p>
  
  <p>I tried changing</p>
  
  <pre><code>requestCode: Int
  </code></pre>
  
  <p>to </p>
  
  <pre><code>requestCode: Int?
  </code></pre>
  
  <p>But then I obviously get an error because the function is not the same as the one from it's superclass.</p>
  
  <p>How can I fix it?</p>