title: Out-projected type prohibits the use of method
body: <p>I can't seem to wrap my head around Kotlin generics, please help</p>
  
  <p>I read <a href="https://stackoverflow.com/questions/40519921/out-projected-type-arraylist-prohibits-the-use-of-public-open-fun-addinde/40520344">here</a> and <a href="https://kotlinlang.org/docs/reference/generics.html" rel="nofollow noreferrer">here</a> and I still can't determine how to make this work. I have a RecyclerView adapter that uses an abstracted parent BaseFieldVH as the ViewHolder class.</p>
  
  <p>So the Adapter class looks like this:</p>
  
  <pre><code>class MyAdapter() : RecyclerView.Adapter&lt;BaseFieldVH&lt;*&gt;&gt;() {
  ... 
      override fun onBindViewHolder(holder: BaseFieldVH&lt;*&gt;, position: Int) {
          holder.bind(data[position])
      }
  }
  </code></pre>
  
  <p>And the ViewHolder implementation looks like this:</p>
  
  <pre><code>abstract class BaseFieldVH&lt;in FF : BaseFormField&gt;
      (itemView: View) : RecyclerView.ViewHolder(itemView) {
      ...
      abstract fun bind(formField: FF)
  }
  </code></pre>
  
  <p>But the actual call to <code>holder.bind(data[position])</code> is displaying the error: </p>
  
  <pre><code>Out-projected type 'BaseFieldVH&lt;*&gt;' prohibits the use of 'public 
  abstract fun bind(formField: FF): Unit defined in ...
  </code></pre>
  
  <p><strong>use in Nothing?</strong></p>
  
  <p>I've also tried defining the Adapter with <code>BaseFieldVH&lt;in Nothing&gt;</code> but then I get a Type Mismatch error for attempting to put Nothing into a function that requires a BaseFormField.</p>
  
  <p><strong>use BaseFormField</strong></p>
  
  <p>Defining the Adapter with <code>BaseFieldVH&lt;iBaseFormField&gt;</code> actually resolves the binding issue, but then in the onCreateViewHolder there is a type mismatch for the view holders:</p>
  
  <pre><code>override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BaseFieldVH&lt;BaseFormField&gt; {
      val itemView: View
      when (viewType) {
          HEADER_TYPE -&gt; {
              itemView = LayoutInflater.from(parent.context)
                      .inflate(R.layout.item_header, parent, false)
              return HeaderVH(itemView)
          }
  </code></pre>
  
  <p>HeaderVH is an extension of BaseFieldVH, and so there's a type mismatch</p>