title: Kotlin databinding with extension methods
body: <p>I'm trying to use Kotlin extension methods inside Android's databinding. For example; calling an onclick handler. So I've made this code:</p>
  
  <p>posttest_list_item.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  </code></pre>
  
  <p></p>
  
  <pre><code>&lt;data&gt;
      &lt;import type="android.view.View"/&gt;
      &lt;import type="com.example.test.post.posttest.PostTestItemViewModelExtensionKt" /&gt;
      &lt;variable
          name="viewModel"
          type="com.example.test.post.posttest.PostTestItemViewModel" /&gt;
  &lt;/data&gt;
  &lt;RelativeLayout
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:paddingLeft="16dp"
      android:paddingRight="16dp"
      android:clickable="true"
      android:onClick="@{(view) -&gt; viewModel.clicked(view)}"
      &gt;
  [...]
  </code></pre>
  
  <p>PostTestItemViewModel.kt</p>
  
  <pre><code>open class PostTestItemViewModel : ViewModel() {
      val postTitle = MutableLiveData&lt;String&gt;()
      val postBody = MutableLiveData&lt;String&gt;()
  
     /**
      * Binds the required properties/entities to this ViewModel
      */
     fun bind(post: Post) {
         postTitle.value = post.title
         postBody.value = post.body
     }
  }
  </code></pre>
  
  <p>PostTestItemViewModelExtension.kt</p>
  
  <pre><code>fun PostTestItemViewModel.clicked(v: View) {
      this.postTitle.value = "clicked"
  }
  </code></pre>
  
  <p>So when I place the clicked method inside the viewmodel, it works perfectly the way it should be. However, when I create it as an extension method, I get the following error on compilation:</p>
  
  <blockquote>
    <p>e: [kapt] An exception occurred: android.databinding.tool.util.LoggedErrorException: Found data binding errors.
    cannot find method clicked(android.view.View) in class ...PostItemViewModel</p>
  </blockquote>
  
  <p>I've tried different things already, such as changing the <code>android:onclick</code> tag to <code>PostTestItemViewModelExtensionKt</code> instead of <code>viewModel</code>. Unfortunately all the things don't seem to work. So it looks like the extension method is getting generated after the databinding takes place. Is there a way around this or am I still doing something wrong? Or is it just not possible to bind extension methods?</p>
  
  <p>I'm using Kotlin version 1.2.71, gradle 3.2.0 and have the <code>databinding { enabled = true }</code> and <code>kapt { generateStubs = true }</code> added to my .gradle, and have the plugings <code>kotlin-android</code>, <code>kotlin-android-extensions</code> and <code>kotlin-kapt</code> defined.</p>