James Whitehead
08/24/2021, 11:36 AMisInterface ? I see we have isAbstract , isOpen , etc, but I haven't found anything for interface.
2. Follow up question; is MyClass::class.java.interfaces the recommended way to get the interfaces implemented by a given class?Ivan Pavlov
08/24/2021, 12:05 PMIvan Pavlov
08/24/2021, 12:08 PMsupertypes or allSupertypes and process them somehow I guessRob Elliot
08/24/2021, 1:58 PMval KClass<*>.isInterface get() = constructors.isEmpty()
should work.Ivan Pavlov
08/24/2021, 2:01 PMPlease note that the constructors counting solution might not be very precise for general purpose use. For example, Kotlin package facade classes do not have any constructors either, but they are not interfaces (UPD: and their constructors cannot even be reflected with, just as those of anonymous classes,kotlin-reflectand maybe more).KFunction
Rob Elliot
08/24/2021, 2:03 PMJames Whitehead
08/24/2021, 11:06 PMAnyJames Whitehead
08/25/2021, 2:25 AMKClass.isAbstract returns true for an interface. Which is fine for my use case, but probably not very helpful if one were trying to distinguish between a class, abstract class and an interface.