if you have a static java method like: ```public s...
# getting-started
z
if you have a static java method like:
Copy code
public static <T> MyFactory<T> of(Class<T> baseType) { ... }
and you wanted to write a kotlin extension method like:
Copy code
fun <T> MyFactory<T>.withSubTypes(types: List<Class<T>) {
   var factory = this
   types.forEach { factory = factory.withSubType(it) }
   return factory
}
How do you properly type the static method? If you write something like:
Copy code
val factory = MyFactory.of(MyClass::class.java)
              .withSubTypes(listOf(...))
You'll get a syntax error on your list:
Type mismatch. Required: Nothing Found: MyClass
. Adding explicit type arguments doesn't help.
v
Maybe it should be
fun <T> MyFactory<T>.withSubTypes(types: List<Class<T>) {
?
z
Ah my mistake, my actual code does have that
I believe I solved it, I needed my
types: List<Class<T>
to be
types: List<Class<out T>