bbaldino
07/10/2020, 5:12 PMClass<SomeEnumType> from a KType created elsewhere via typeOf<SomeEnumType>()? I feel like it should be possible, but I'm struggling to find the right call to get it.Zach Klippenstein (he/him) [MOD]
07/10/2020, 5:14 PMKType.classifier as? KClassbbaldino
07/10/2020, 5:16 PMKClass there, though, and all I could pass is <*>, no?bbaldino
07/10/2020, 5:16 PMbbaldino
07/10/2020, 5:17 PMprintln(type.classifier as? KClass<*>) It does print as the right type, but it assigns as KClass<*>Big Chungus
07/10/2020, 5:18 PMas KClass<T>bbaldino
07/10/2020, 5:18 PMT here, unfortunately, just the KTypeBig Chungus
07/10/2020, 5:19 PMZach Klippenstein (he/him) [MOD]
07/10/2020, 5:19 PMas KClass<*> if you don’t have the typebbaldino
07/10/2020, 5:19 PMT, I might be able to work something out, but I wondered if I could get that from the KTypeZach Klippenstein (he/him) [MOD]
07/10/2020, 5:20 PMclassifier will be the KClass of your enum typebbaldino
07/10/2020, 5:20 PM<T extends Enum<T>> T getEnum(Class<T> var1, String var2); so I have to get a Class<T> with <T extends Enum<T>>bbaldino
07/10/2020, 5:20 PMtype.isSubtypeOf(typeOf<Enum<*>>()) to check that it is an enumZach Klippenstein (he/him) [MOD]
07/10/2020, 5:21 PMas KClass<Enum<*>>?bbaldino
07/10/2020, 5:21 PMBig Chungus
07/10/2020, 5:21 PMbbaldino
07/10/2020, 5:21 PMbbaldino
07/10/2020, 5:21 PMbbaldino
07/10/2020, 5:23 PMval c = (type.classifier as KClass<Enum<*>>).java helps a little...bbaldino
07/10/2020, 5:23 PMbbaldino
07/10/2020, 5:35 PMgetEnum extension function for this class in Kotlin and do that. But now I'm even trying that and it's still eluding me. Is it possible given a String and a KType of an enum to create an instance of that enum using valueOf(someString) ?Zach Klippenstein (he/him) [MOD]
07/10/2020, 5:36 PMType of a KType, maybe that would help?bbaldino
07/10/2020, 5:37 PMbbaldino
07/10/2020, 5:42 PMEnum<*>, but because of how Enum type bounds are set, it wants the boundary to be T : Enum<Enum<T>> and it complains that Enum<*> isn't a subtype of Enum<Enum<*>>diesieben07
07/13/2020, 9:00 AMNothing helps you:
ktype.classifier as KClass<Nothing>bbaldino
07/13/2020, 3:56 PMKClass<Nothing> would satisfy T : Enum<T>...that's pretty slickZach Klippenstein (he/him) [MOD]
07/13/2020, 4:24 PMNothing is the bottom type, so it is a subtype of every possible type.bbaldino
07/13/2020, 4:25 PMNothing.