title: Subclass of AsyncTask in Kotlin - unable to use primary constructor parameter within onPostExecute
body: <p>I have a subclass of <code>AsyncTask</code> implemented in Kotlin:</p>
  
  <pre><code>class SignUpTask(responseHandler: SignUpTaskResponseHandler): AsyncTask&lt;Agent, Void, Boolean&gt;() {
      override fun doInBackground(vararg params: Agent?): Boolean {
          // Some awesome code
          return true
      }
      override fun onPostExecute(result: Boolean?) {
          result?.let {
              if (it) {
                  responseHandler.agentCreationSucceeded()
              } else {
                  // agent creation failed
              }
          }
      }
  }
  </code></pre>
  
  <p>Problem is - I am getting below error at this line <code>responseHandler.agentCreationSucceeded()</code>:</p>
  
  <blockquote>
    <p>Unresolved reference: responseHandler</p>
  </blockquote>
  
  <p>I can make it work by explicitly declaring a property and assigning it the parameter passed in constructor:</p>
  
  <pre><code>class SignUpTask(responseHandler: SignUpTaskResponseHandler): AsyncTask&lt;Agent, Void, Boolean&gt;() {
          val internalResponseHandler = responseHandler // explicit assignment to make it work inside onPostExecute
          override fun doInBackground(vararg params: Agent?): Boolean {
              // Some awesome code
              return true
          }
          override fun onPostExecute(result: Boolean?) {
              result?.let {
                  if (it) {
                      // Works only after explicit assignment?
                      internalResponseHandler.agentCreationSucceeded()
                  } else {
                      // agent creation failed
                  }
              }
          }
      }
  </code></pre>
  
  <p>Any ideas on why this overhead or am I missing anything over here?</p>