Failed type inference


#1

Kotlin: Type parameter bound for T in fun <T> setAdapter(adapter : T?) : Unit where T : android.widget.ListAdapter?, T : android.widget.Filterable? is not satisfied: inferred type ArrayAdapter<String> is not a subtype of {ListAdapter & Filterable}?

is generated by

``

val adapter = ArrayAdapter<String>(this, org.holoeverywhere.R.layout.simple_dropdown_item_1line, names)
val completion = findViewById(R.id.kayak_flight_deals_area) as AutoCompleteTextView
completion.setAdapter(adapter)
  

setAdapter definition is below
``

public <T extends android.widget.ListAdapter & android.widget.Filterable>  void setAdapter(T adapter) { /* compiled code */ }

ArrayAdapter definition is as follow

``


public class ArrayAdapter<T> extends BaseAdapter implements Filterable

public abstract class BaseAdapter implements android.widget.ListAdapter, android.widget.SpinnerAdapter {


#2

My workaround is to implement the same code in Java and use it in Kotlin class

`

package com.silverkeytech.android_rivers.creators;

import org.holoeverywhere.ArrayAdapter;
import org.holoeverywhere.widget.AutoCompleteTextView;
import org.holoeverywhere.app.Activity;

import java.util.ArrayList;

public class AirportAutoComplete {
  public static AutoCompleteTextView getUI(Activity context, Integer uiId, ArrayList<String> names){
  AutoCompleteTextView completion = (AutoCompleteTextView) context.findViewById(uiId);
  ArrayAdapter<String> adapter = new ArrayAdapter<String>(context, org.holoeverywhere.R.layout.simple_dropdown_item_1line, names);
  completion.setAdapter(adapter);
  return completion;
  }
}


#3

Could you please post a bug about it? Thank you.


#4

http://youtrack.jetbrains.com/issue/KT-3358