title: Adapter data mutableList crash when modified
body: <p>I'm making a SearchView Filter for a RecyclerView, in my Filter object, in the fun 'publishResults', my app crash because i'm trying to modify a mutableListOf, but the data.clear() and data.addAll() cause an error</p>
  
  <p>Every modification to the list seems to make the app crash, I've never seen this error despite all other list I've tried to modify. I think the problem come from the fact that it's used by the recyclerView but I have no clue why, I've find nothing on internet and even less with kotlin language.
  Also it seems like there is a big problem when trying to cast the <code>results?.values</code> to a Collection.</p>
  
  <p>here is my full Adapter code</p>
  
  <pre><code>class SmallCatchAdapter(val clickListener: FishModelListener) : RecyclerView.Adapter&lt;SmallCatchAdapter.ViewHolder&gt;(), Filterable {
  
  var data = mutableListOf&lt;FishModel&gt;()
      set(value) {
          field = value
          notifyDataSetChanged()
      }
  
  var dataFull = listOf&lt;FishModel&gt;()
  
  override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
      return ViewHolder.from(parent)
  }
  
  override fun getItemCount() = data.size
  
  override fun onBindViewHolder(holder: ViewHolder, position: Int) {
      val item = data[position]
      holder.bind(item, clickListener)
  }
  
  class ViewHolder private constructor(val binding: ItemListSmallCatchBinding): RecyclerView.ViewHolder(binding.root) {
      fun bind(item : FishModel, clickListener: FishModelListener) {
          binding.fishModel = item
          binding.clickListener = clickListener
          binding.executePendingBindings()
      }
  
      companion object{
          fun from(parent: ViewGroup): ViewHolder {
              val layoutInflater = LayoutInflater.from(parent.context)
              val binding = ItemListSmallCatchBinding.inflate(layoutInflater, parent, false)
  
              return ViewHolder(binding)
          }
      }
  
  }
  
  override fun getFilter(): Filter {
      return fishListFilter
  }
  
  private val fishListFilter = object : Filter() {
      override fun performFiltering(constraint: CharSequence?): FilterResults {
          val dataFiltered = mutableListOf&lt;FishModel&gt;()
          if (constraint == null || constraint.isEmpty()) {
              dataFiltered.addAll(dataFull)
          } else {
              val filterPattern: String = constraint.toString().toLowerCase().trim()
              for (item in dataFull) {
                  if(item.name.toLowerCase().contains(filterPattern)) {
                      dataFiltered.add(item)
                  }
              }
          }
          val results = FilterResults()
          results.values = dataFiltered
          return results
      }
  
      override fun publishResults(constraint: CharSequence?, results: FilterResults?) {
          data.clear()
          data.addAll(results?.values as MutableList&lt;FishModel&gt;)
          notifyDataSetChanged()
      }
  }
  
  }
  
  class FishModelListener(val clickListener: (fishModelId: Int) -&gt; Unit) {
      fun onClick(fishModel: FishModel) = clickListener(fishModel.speciesID)
  
  }
  </code></pre>
  
  <p><strong>Where it crashes</strong></p>
  
  <pre><code>override fun publishResults(constraint: CharSequence?, results: FilterResults?) {
              data.clear()
              data.addAll(results?.values as Collection&lt;FishModel&gt;)
              notifyDataSetChanged()
          }
  </code></pre>
  
  <p>The error:</p>
  
  <pre><code>java.lang.UnsupportedOperationException
      at java.util.AbstractList.remove(AbstractList.java:161)
      at java.util.AbstractList$Itr.remove(AbstractList.java:374)
      at java.util.AbstractList.removeRange(AbstractList.java:571)
      at java.util.AbstractList.clear(AbstractList.java:234)
  </code></pre>
  
  <p>Everything worked well before i implement this functionality, now I've also noticed that this bug has somehow messed with my Room Query, one (and only one) of my coroutineScope is never launched, everythings else is ok</p>
  
  <p>(Sorry for the mistakes, i'm not english)</p>