I have an issue where I want to use a generic type, and the type has overloaded methods with a Collection and varargs. When I use Any as type parameter, I cant pass in a List as argument.
val productType = ComboBox<Any>("Product type")
// public void setItems(Collection<T> items) {
// public void setItems(T... items) {
productType.setItems(listOf("1","2")) // Not possible
Is there any better solution besides converting the list to an array via: productType.setItems(*listOf("1","2").toTypedArray())
Edit: Working example to try out:
class Foo<T>() {
fun setItems(items: Collection<T>) {}
fun setItems(vararg items: T) {}
}
val f = Foo<Any>()
f.setItems(listOf("1", "2"))
>`, thus leading to the ambiguity. `ComboBox<*>` is not possible.