https://kotlinlang.org logo
Title
c

Charlie Tapping

03/15/2023, 12:35 PM
Is it significantly faster to find all classes with a particular annotation than to find all inheritors of a particular interface?
j

Jiaxiang

03/15/2023, 5:31 PM
These 2 actions are not same actions anyway. Generally I would say blindly finding all inheritors of a particular interface will be slower as you need to traverse all classes and check their super types. But if you are looking at a sealed interface, it will get faster.
e

efemoney

03/15/2023, 10:03 PM
@Jiaxiang just curious, why will it be faster for sealed interfaces, is there some special resolution logic around this?
j

Jiaxiang

03/15/2023, 10:06 PM
Compiler comes with sealed subclass support so KSP can simply query compiler for that matter instead of traversing all classes in the project. The more detailed explanation on why compiler supports it is probably not relevant here for KSP’s purpose.
e

efemoney

03/15/2023, 10:11 PM
Yeah thats answers my question, thanks!