KaSymbolRelationProvider¶
@SubclassOptInRequired(markerClass = [KaSessionComponentImplementationDetail::class])
interface KaSymbolRelationProvider : KaSessionComponent
Inheritors¶
Properties¶
allOverriddenSymbols¶
abstract val KaCallableSymbol.allOverriddenSymbols: Sequence<KaCallableSymbol>
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:
-
Regular
KaNamedFunctionSymbolthat is not a Java accessor method of a synthetic Java property: overridden function symbols. -
Java
KaNamedFunctionSymbolthat corresponds to the getter or setter of aKaSyntheticJavaPropertySymbol: the same property symbols as the corresponding synthetic property accessor, not Java accessor methods. -
KaPropertySymbol, includingKaSyntheticJavaPropertySymbol: overridden property symbols. -
KaPropertyGetterSymbol: overridden properties of the containing property, not getter symbols. -
KaPropertySetterSymbol: overridden mutable properties whose setters are overridden by this setter. -
KaValueParameterSymbolwithKaValueParameterSymbol.primaryConstructorProperty: overridden symbols of that generated property. -
Other callable kinds: an empty sequence.
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¶
abstract val KaSymbol.containingDeclaration: KaDeclarationSymbol?
The KaDeclarationSymbol which contains this symbol, or null if there is no containing declaration:
-
For top-level declarations, a containing
KaScriptSymbol, ornullfor 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¶
abstract val KaSymbol.containingFile: KaFileSymbol?
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¶
abstract val KaSymbol.containingModule: KaModule
The KaModule which contains this symbol.
containingSymbol¶
abstract val KaSymbol.containingSymbol: KaSymbol?
The KaSymbol which contains this symbol, or null if there is no containing declaration:
-
For top-level declarations, a
KaFileSymbol, or aKaScriptSymbolif the file is a script file. -
For
KaScriptSymbols, aKaFileSymbol. -
For class members, the containing class symbol.
-
For local declarations, the symbol of the containing declaration.
directlyOverriddenSymbols¶
abstract val KaCallableSymbol.directlyOverriddenSymbols: Sequence<KaCallableSymbol>
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¶
abstract val KaCallableSymbol.fakeOverrideOriginal: KaCallableSymbol
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:
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¶
abstract val KaSamConstructorSymbol.functionalInterface: KaClassLikeSymbol
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¶
abstract val KaClassLikeSymbol.functionalInterfaceFunction: KaNamedFunctionSymbol?
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
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¶
abstract val KaCallableSymbol.intersectionOverriddenSymbols: List<KaCallableSymbol>
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¶
abstract val KaClassLikeSymbol.samConstructor: KaSamConstructorSymbol?
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¶
abstract val KaNamedClassSymbol.sealedClassInheritors: List<KaNamedClassSymbol>
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¶
inline fun KaLifetimeOwner.assertIsValidAndAccessible()
getExpectsForActual¶
abstract fun KaDeclarationSymbol.getExpectsForActual(): List<KaDeclarationSymbol>
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:
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() {} }
implementationState¶
abstract fun KaCallableSymbol.implementationState(implementerClassSymbol: KaClassSymbol): KaCallableImplementationState?
Returns the KaCallableImplementationState of the given KaCallableSymbol in the context of implementerClassSymbol.
Returns null if:
-
The symbol is a top-level callable;
-
The symbol is declared in a class or interface that is not a supertype of
implementerClassSymbol; -
If the symbol is non-implementable (for example, it is a
KaConstructorSymbol, or aKaValueParameterSymbol).
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¶
abstract fun KaClassSymbol.isDirectSubClassOf(superClass: KaClassSymbol): Boolean
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¶
fun KaLifetimeOwner.isValid(): Boolean
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.