Skip to content

KaSymbolRelationProvider

@SubclassOptInRequired(markerClass = [KaSessionComponentImplementationDetail::class])
interface KaSymbolRelationProvider : KaSessionComponent

Inheritors

Properties

allOverriddenSymbols

All explicitly declared (non-fake) callable symbols overridden by this callable symbol.

The sequence implicitly unwraps substituted and intersection override symbols (see INTERSECTION_OVERRIDE and SUBSTITUTION_OVERRIDE).

The sequence doesn't include the original overridden declaration of a delegated symbol (for that, use fakeOverrideOriginal).

Depending on this callable symbol, the sequence contains:

The sequence may include KaSyntheticJavaPropertySymbols in Java/Kotlin hierarchies.

Example

abstract class C {
    open fun foo() { ... }
}

abstract class B : C() {
    override fun foo() { ... }
}

class A : B() {
    override fun foo() { ... }
}

For A.foo, allOverriddenSymbols contains both overridden super-declarations, B.foo and C.foo.

See also

containingDeclaration

The KaDeclarationSymbol which contains this symbol, or null if there is no containing declaration:

  • For top-level declarations, a containing KaScriptSymbol, or null for non-script declarations.

  • For class members, the containing class symbol.

  • For property members, the corresponding property.

  • For local declarations, the symbol of the containing declaration.

containingFile

The KaFileSymbol which contains this symbol, or null if this symbol is already a KaFileSymbol, since it has no containing file. Also null for Java and library declarations.

containingModule

The KaModule which contains this symbol.

containingSymbol

The KaSymbol which contains this symbol, or null if there is no containing declaration:

directlyOverriddenSymbols

Explicitly declared (non-fake) callable symbols that are directly overridden by this callable symbol.

The sequence implicitly unwraps substituted and intersection override symbols (see INTERSECTION_OVERRIDE and SUBSTITUTION_OVERRIDE).

The sequence doesn't include the original overridden declaration of a delegated symbol (for that, use fakeOverrideOriginal).

Symbol kinds follow the same mapping as allOverriddenSymbols. In particular, property accessor symbols and Java accessor methods of synthetic Java properties are represented by property symbols rather than accessor or Java method symbols. Setters include only mutable properties whose setters are directly overridden.

Example

abstract class C {
    open fun foo() { ... }
}

abstract class B : C() {
    override fun foo() { ... }
}

class A : B() {
    override fun foo() { ... }
}

For A.foo, directlyOverriddenSymbols contains only the directly overridden super-declaration, B.foo.

See also

fakeOverrideOriginal

The original declared symbol for this callable symbol, after unwrapping fake override KaCallableSymbols if needed.

In a class scope, a symbol may be derived from symbols declared in super classes. For example, consider the following:

public interface A<T> {
  public fun foo(t: T)
}

public interface B : A<String> {
}

In the class scope of B, there is a callable symbol foo that takes a String. This symbol is derived from the original symbol in A that takes the type parameter T (fake override). Given such a fake override symbol, fakeOverrideOriginal is the original declared symbol.

Such a situation can also happen for intersection symbols (in case of multiple supertypes containing symbols with an identical signature after specialization) and delegation.

See also

functionalInterface

The KaClassLikeSymbol of the corresponding functional (SAM) interface.

Example

fun interface MyPredicate {
    fun test(value: Int): Boolean
}

val p = MyPredicate { it > 0 }  // MyPredicate is a SAM constructor call

For the MyPredicate SAM constructor symbol, functionalInterface is the symbol for the MyPredicate interface.

functionalInterfaceFunction

The single abstract function of a functional interface, or null if this class is not a functional interface.

A functional interface has exactly one abstract function. In Kotlin, it must be declared with the fun modifier. The function may be inherited from a parent interface.

Example

fun interface MyPredicate {
    fun test(value: Int): Boolean
}

For MyPredicate, functionalInterfaceFunction is the symbol for the test function.

See also

The single abstract function of the functional interface that this SAM constructor creates.

Example

fun interface MyPredicate {
    fun test(value: Int): Boolean
}

val p = MyPredicate { it > 0 }  // MyPredicate is a SAM constructor call

For the MyPredicate SAM constructor symbol, functionalInterfaceFunction is the symbol for the test function.

See also

intersectionOverriddenSymbols

All callable symbols overridden by this callable symbol if it is an intersection override, or an empty list otherwise.

Symbol kinds follow the same mapping as allOverriddenSymbols. In particular, property accessor symbols and Java accessor methods of synthetic Java properties are represented by property symbols rather than accessor or Java method symbols. Setters include only mutable properties whose setters are overridden by the intersection override.

Example

interface Foo<T> {
    fun foo(value: T)
}

interface Bar {
    fun foo(value: String)
}

interface Both : Foo<String>, Bar

The Both interface contains an automatically generated intersection override for foo(). For it, intersectionOverriddenSymbols is a list of two unsubstituted symbols: Foo.foo(T) and Bar.foo(String).

See also

originalConstructorIfTypeAliased

The original KaConstructorSymbol for a type-aliased constructor, or null otherwise.

Currently, this property is marked as experimental because it might be joined with fakeOverrideOriginal in the future.

samConstructor

The associated KaSamConstructorSymbol if this KaClassLikeSymbol is a functional interface type (SAM).

Example

fun interface MyPredicate {
    fun test(value: Int): Boolean
}

val p = MyPredicate { it > 0 }  // MyPredicate is a SAM constructor call

For MyPredicate, samConstructor is the symbol for the synthetic SAM constructor that enables the MyPredicate { ... } lambda syntax.

sealedClassInheritors

The inheritors of the given sealed class.

The list is limited to class symbols which are analyzable in the use-site KaModule. While sealed class inheritors can usually only be defined in the same module, there are more complex rules around multiplatform projects. If the use-site module is a common source set and additional sealed inheritors are declared in a platform source set, sealedClassInheritors will not include those additional platform sealed inheritors.

Throws

IllegalArgumentException

if the given class is not a sealed class.

token

abstract val token: KaLifetimeToken

The KaLifetimeToken which determines the lifetime of the lifetime owner.

Functions

assertIsValidAndAccessible

getExpectsForActual

Returns an expect symbol for the given actual symbol, if it is available. The function may return multiple expect symbols in case of ambiguity errors.

hasConflictingSignatureWith

abstract fun KaFunctionSymbol.hasConflictingSignatureWith(other: KaFunctionSymbol, targetPlatform: TargetPlatform): Boolean

Returns whether this declaration has a conflicting signature with other based on platform-specific checks from targetPlatform.

Note that it doesn't consider function names or their visibility, only their signatures. In other words, it calculates whether two functions would conflict with each other when named equally and positioned in the same scope.

Example for JVM platform:

fun foo(vararg x: Int) {}

fun bar(x: IntArray) {}

Two functions foo and bar have the same JVM signature (as vararg parameter is transformed into a regular IntArray parameter). However, these two functions can coexist on non-JVM platforms.

``kotlin fun foo() {}

fun main() { fun bar() {} }

These two functions `foo` and `bar` have signatures, which are conflicting on every platform.

implementationState

Returns the KaCallableImplementationState of the given KaCallableSymbol in the context of implementerClassSymbol.

Returns null if:

The implementation state describes whether a callable is already implemented, has an inherited implementation, can be overridden, or must be explicitly overridden in the given class.

See also

isDirectSubClassOf

Checks if this class has superClass listed as its direct superclass.

The class is not considered to be a direct subclass of itself, so myClass.isDirectSubClassOf(myClass) is always false.

isSubClassOf

abstract fun KaClassSymbol.isSubClassOf(superClass: KaClassSymbol): Boolean

Checks if this class has superClass as its superclass somewhere in the inheritance hierarchy.

The class is not considered to be a subclass of itself, so myClass.isSubClassOf(myClass) is always false.

isValid

Whether the lifetime owner is still valid, i.e. we are still in the scope of the lifetime owner's regular lifetime.

withValidityAssertion

inline fun <R> KaLifetimeOwner.withValidityAssertion(action: () -> R): R

Executes action only if the KaLifetimeOwner is still valid and accessible. Otherwise, throws a validity exception based on the concrete violation.