KaClassSymbol
Represents a class, object, or interface declaration.
Use Cases
Analyzing class hierarchies. Use
superTypesto navigate the inheritance hierarchy of a class and analyze its relationships with other classes and interfaces.Exploring class members. Use
declaredMemberScopeandmemberScopeto access members of a class, including functions, properties, and nested classes.
Hierarchy
Inherits from KaClassLikeSymbol.
Notable inheritors: KaNamedClassSymbol, KaAnonymousObjectSymbol.
Members
val classKind: KaClassKindThe class kind (ordinary class, interface, enum class, etc.).
val superTypes: List<KaType>A list of the direct supertypes of the class. If the class has no explicit supertypes, the supertype will be
Any, or a special supertype such asEnumfor enum classes.
Type utilities
fun KaClassSymbol.isSubClassOf(superClass: KaClassSymbol): BooleanCheck if the given class has
superClassas its superclass in its inheritance hierarchy.fun KaClassSymbol.isDirectSubClassOf(superClass: KaClassSymbol): BooleanCheck if the given class has
superClasslisted as its direct superclass.
Scope utilities
val KaDeclarationContainerSymbol.memberScope: KaScopeA scope with non-static callables and nested classes. Also includes members inherited from the supertypes.
val KaDeclarationContainerSymbol.declaredMemberScope: KaScopeA scope containing non-static callables and nested classes. Unlike
memberScope, the returned scope does not contain members inherited from supertypes.val KaDeclarationContainerSymbol.staticMemberScope: KaScopeA scope containing static members, possibly including members from supertypes. The behavior differs based on whether the declaration is a Kotlin or Java one.
For Kotlin classes, the scope contains static declarations declared only in the given declaration itself.
For Java classes, the scope also contains callables from supertypes, excluding static callables from super-interfaces. This follows Kotlin's rules about static inheritance in Java classes, where static callables are propagated from superclasses, but nested classes are not.
val KaDeclarationContainerSymbol.staticDeclaredMemberScope: KaScopeA scope containing static members of the given declaration. Unlike
staticMemberScope, the returned scope does not contain members from supertypes.val KaDeclarationContainerSymbol.combinedMemberScope: KaScopeA scope containing all declarations from both
memberScopeandstaticMemberScope.val KaDeclarationContainerSymbol.combinedDeclaredMemberScope: KaScopeA scope containing both non-static and static members of the given declaration. Unlike
combinedMemberScope, the returned scope does not contain members from supertypes.val KaDeclarationContainerSymbol.delegatedMemberScope: KaScopeA scope containing synthetic fields created by interface delegation.
Other utilities
val KaClassSymbol.annotationApplicableTargets: Set<KotlinTarget>?A set of applicable targets for an annotation class symbol, or
nullif the symbol is not an annotation class.Experimental API.