bbaldino
12/02/2019, 8:57 PMClass<T Extends Enum<T>>  out of it.  for example:
fun <T : Any>test(valueType: KClass<T>) {
    when (valueType) {
        Enum::class -> {
            // How to get 'x' to be Class<T> where T extends Enum<T> ?
            val x = valueType.java
        }
        else -> TODO()
    }
}bbaldino
12/02/2019, 8:58 PMval x = valueType.java as Class<Enum> complains about the missing type argument for Enumbbaldino
12/02/2019, 8:58 PMvalueType.java as Class<Enum<T>> complains because it doesn't see T as within the required boundstseisel
12/02/2019, 9:34 PMfun <T : Enum<T>> test(valueType: KClass<T>)
is the equivalent of
void <T extends Enum<T>> test(Class<T> valueType)bbaldino
12/02/2019, 9:35 PMbbaldino
12/02/2019, 10:07 PMbbaldino
12/02/2019, 10:07 PMDaniel Seemaier
12/03/2019, 8:23 AMvalueType.java as Class<Enum<*>> work?bbaldino
12/03/2019, 5:05 PMbbaldino
12/03/2019, 5:06 PMKClass<T> and then, based on that type, returns an appropriate "getter" function which handles that type:bbaldino
12/03/2019, 5:06 PMoverride fun <T : Any> getterFor(valueType: KClass<T>): (String) -> T {
        return when(valueType) {
            Boolean::class -> { path -> config.getBoolean(path) as T }
            Number::class -> { path -> config.getNumber(path) as T }
            Int::class -> { path -> config.getInt(path) as T }
            Long::class -> { path -> config.getLong(path) as T }
            Double::class -> { path -> config.getDouble(path) as T }
            String::class -> { path -> config.getString(path) as T }
            Enum::class -> { path ->
                val c = valueType.java as Class<Enum<*>>
                config.getEnum(c, path) as T
            }bbaldino
12/03/2019, 5:07 PMgetEnum method i'm trying to call has the following signature:bbaldino
12/03/2019, 5:07 PMpublic <T extends Enum<T>> T getEnum(Class<T> enumClass, String path);bbaldino
12/03/2019, 5:07 PMval c = valueType.java as Class<Enum<*>> i get this error:bbaldino
12/03/2019, 5:07 PM