Skip to content

KaSession

KaSession, also called an analysis session, is the entry point to all frontend-related work. It has the following contracts:

  • It should not be accessed outside a read action.

  • It should only be accessed in restricted analysis mode (see KotlinRestrictedAnalysisService in the platform interface) when restricted analysis is allowed by the Analysis API platform.

  • It should not be accessed from the event dispatch thread (EDT) or a write action unless explicitly allowed (allowAnalysisOnEdt, allowAnalysisFromWriteAction).

  • It should not be leaked outside the analyze call it was created in. To ensure that an analysis session isn't leaked, there are additional conventions, explained further below.

  • All lifetime ownerss retrieved from an analysis session should not be leaked outside the analyze call that spawned the analysis session.

To pass a lifetime owner from one analyze call to another, use a pointer:

To create a KaSession, please use analyze or one of its siblings.

Conventions to avoid leakage

It is crucial to avoid leaking the analysis session outside the read action it was created in, as the analysis session itself and all lifetime owners retrieved from it will become invalid. An analysis session also shouldn't be leaked from the analyze call it was created in.

It is forbidden to store an analysis session in a variable, parameter, or property. From the analyze block which provides the analysis session, the analysis session should be passed to functions via an context parameter. For example:

context(session: KaSession)
fun foo() { ... }

PsiElement as input

Some API components accept PsiElements as input. For example, KaSymbolProvider.symbol takes a KtDeclaration and returns a KaDeclarationSymbol for it.

In this case, the symbol may be created only for elements which are a part of the current KaSession. And it means that KaAnalysisScopeProvider.canBeAnalysed is true for such elements.

If this condition is not met, an exception will be thrown to prevent undefined behavior.

Nested analysis

While analyze calls can be nested, it is currently not recommended to use lifetime owners from the outer analysis context in the inner analysis context. This section illustrates the reasons behind this recommendation.

As there is one analysis session per use-site module, in the best case, the analyzed element will be from the same module. Then the nested analyze call will simply perform the analysis in the same analysis session context. As such, it would be possible to use a symbol from the outer analysis context in the inner analyze call. But if it's the same use-site module, it's better to pass the analysis session down the call chain directly, instead of calling analyze again. In addition, relying on two elements having the same use-site module is an open invitation for bugs.

In more problematic cases, nested analysis may lead to various issues. First of all, a KaLifetimeOwner can usually only be accessed in the session where it was created. Nesting analyze and starting analysis from a different use-site module will effectively change the current KaSession context. Any calls to symbols created in other sessions will result in an exception (unless the Analysis API platform defines different accessibility rules, such as the Standalone Analysis API).

Furthermore, even if such an access exception wasn't thrown, it is conceptually problematic to access a symbol in a different use-site context. Symbols are always viewed from a specific use-site context. It is unclear whether the symbol would even exist in the other use-site context. And even if the symbol is accessible, analyzing it may lead to different results due to differences in the use site's dependencies. For example, the supertypes of a class symbol may resolve to different declaration symbols.

In summary, using lifetime owners from an outer context in a nested analyze block will likely lead to an access exception given the accessibility rules of lifetime owners. And even if this wasn't the case, there's a conceptual problem with using a lifetime owner in the wrong session, as lifetime owners such as symbols are always viewed from a specific use-site context.

Example

// DO NOT DO THIS
analyze(element1) {
    val symbol1 = element1.symbol
    analyze(element2) {
         val type1 = symbol1.returnType // <-- error when `element1.module` != `element2.module`
    }
}

Properties

allOverriddenSymbols

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

allSupertypes

All supertypes of the given KaType. The resulting sequence is ordered by a breadth-first traversal of the class hierarchy, without duplicates.

analysisScope

abstract val analysisScope: GlobalSearchScope

A GlobalSearchScope which spans the files that can be analyzed by the current KaSession.

applicableAnnotationTargets

A set of applicable targets for an annotation class symbol, or null if the symbol is not an annotation class.

arrayElementType

abstract val KaType.arrayElementType: KaType?

The array type's element type if the given KaType is a primitive type array or Array, and null otherwise.

augmentedByWarningLevelAnnotations

A KaType derived from the given type by enforcing warning-level nullability annotations. If the derived type doesn't differ from the original type, the original type is used.

builtinFunctionTypeFamilies

builtinTypes

KaType instances for built-in types.

callableSymbol

abstract val PsiMember.callableSymbol: KaCallableSymbol?

A KaCallableSymbol for the given PsiMember method or field, or null for local declarations and Kotlin light classes.

canBeOperator

Whether the function symbol meets all the requirements to be declared as an operator function.

classSymbol

A KaClassSymbol for the given KtClassOrObject, or null for KtEnumEntry declarations.

combinedDeclaredMemberScope

A KaScope containing all members explicitly declared in the given KaDeclarationContainerSymbol.

combinedMemberScope

commonSupertype

The common supertype of the given KaTypes.

The common supertype of the given KaTypes.

compilerPluginGeneratedDeclarations

Declarations generated by compiler plugins for this module, not including the generated declarations for dependencies of this module.

containingDeclaration

The KaDeclarationSymbol which contains this symbol, or null if there is no 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.

containingFileAnnotations

File-level annotations (@file:SomeAnnotation) of the source file this top-level KaDeclarationSymbol was defined in, or null for a nested declaration.

containingJvmClassName

The containing JVM class name for the given KaCallableSymbol.

containingModule

The KaModule which contains this symbol.

containingSymbol

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

contextSensitiveResolutionStatus

The context-sensitive resolution status of the KtSimpleNameExpression: whether the name is already resolved through context-sensitive resolution, and whether a redundant explicit qualifier or import could be removed in favor of it.

declarationScope

A KaScope containing unsubstituted declarations from the KaType's underlying declaration.

declaredMemberScope

A KaScope containing the non-static callables (functions, properties, and constructors) and inner classes explicitly declared in the given KaDeclarationContainerSymbol.

defaultAnnotationTargets

A set of annotation targets matching for the given symbol, or null if the symbol cannot be annotated. Annotations with one of targets from the returned set can be placed on the KaSymbol without an explicit use-site target.

defaultInitializer

The default initializer for the given KaType, or null if the type is neither nullable, a primitive, nor a string.

defaultType

The representation of this in terms of KaType.

defaultTypeWithStarProjections

The representation of this in terms of KaType.

delegatedMemberScope

A KaScope containing synthetic callables (functions and properties) created by interface delegation.

deprecation

The deprecation status of the given symbol, or null if the symbol is not deprecated.

directlyOverriddenSymbols

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

directSupertypes

The direct supertypes of the given KaType.

expandedSymbol

The class symbol backing the given KaType, if available.

expectedType

abstract val PsiElement.expectedType: KaType?

The expected KaType for the given PsiElement if it is an expression, or null if the element does not have an expected type. The expected type represents the type that is expected for an expression at a specific location in the code.

expressionType

The type of the given KtExpression, or null if it does not have a type.

fakeOverrideOriginal

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

fileScope

A KaScope containing the top-level declarations (such as classes, functions and properties) in the given KaFileSymbol.

fullyExpandedType

The type that corresponds to the given KaType with fully expanded type aliases.

functionalInterface

functionalInterfaceFunction

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

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

functionType

The function type of the given KtFunction.

functionTypeFamily

The function type family of the given KaType, or null if the type is not a function type.

hasFlexibleNullability

Whether the KaType is a org.jetbrains.kotlin.analysis.api.types.KaFlexibleType / org.jetbrains.kotlin.analysis.api.types.KaDynamicType with flexible nullability or org.jetbrains.kotlin.analysis.api.types.KaErrorType with unknown nullability. Both safe and ordinary calls are valid on such types.

implicitReceiverSmartCasts

The list of implicit receiver smart casts which have refined the expression's implicit receivers to a more specific type. These smart casts are required for the expression to be evaluated. The list does not include smart casts for explicit receivers.

importableFqName

abstract val KaSymbol.importableFqName: FqName?

A FqName which can be used to import the given symbol, or null if the symbol cannot be imported.

importingScopeContext

A KaScopeContext formed from all imports in the KtFile.

intersectionOverriddenSymbols

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

isAnyType

abstract val KaType.isAnyType: Boolean

Whether the KaType is an Any type.

isArrayOrPrimitiveArray

Whether the KaType is an array or a primitive array type.

isBooleanType

abstract val KaType.isBooleanType: Boolean

Whether the KaType is a Boolean type.

isByteType

abstract val KaType.isByteType: Boolean

Whether the KaType is a Byte type.

isCharSequenceType

Whether the KaType is a CharSequence type.

isCharType

abstract val KaType.isCharType: Boolean

Whether the KaType is a Char type.

isDefinitelyNotNull

Whether this expression is definitely not null.

isDefinitelyNull

Whether this expression is definitely null, based on the declared nullability and smart cast types derived from data-flow analysis facts.

isDenotable

abstract val KaType.isDenotable: Boolean

Whether the KaType is denotable. A denotable type can be expressed in Kotlin code, as opposed to being only constructible via compiler type operations (such as type inference).

isDeprecated

abstract val KaSymbol.isDeprecated: Boolean

Whether the symbol is deprecated at any level.

isDoubleType

abstract val KaType.isDoubleType: Boolean

Whether the KaType is a Double type.

isFloatType

abstract val KaType.isFloatType: Boolean

Whether the KaType is a Float type.

isFromResolveExtension

Whether the given KtElement is provided by a KaResolveExtension.

isFunctionalInterface

Whether the KaType is a functional interface type, such as Runnable. Such types are also known as SAM types.

isFunctionType

abstract val KaType.isFunctionType: Boolean

Whether the KaType is a kotlin.Function type.

isImplicitReferenceToCompanion

Checks if the KtSimpleNameExpression is an implicit reference to a companion object via the containing class.

isInline

Whether the property is an inline property. A property is considered inline when both of its accessors are inline or when it has the inline keyword. The inline keyword on a property is syntactic sugar for marking both accessors as inline.

isIntType

abstract val KaType.isIntType: Boolean

Whether the KaType is an Int type.

isKFunctionType

Whether the KaType is a kotlin.reflect.KFunction type.

isKSuspendFunctionType

Whether the KaType is a KSuspendFunction type.

isLongType

abstract val KaType.isLongType: Boolean

Whether the KaType is a Long type.

isMarkedNullable

Whether the KaType is explicitly marked as nullable, i.e., is represented as T?.

isNestedArray

abstract val KaType.isNestedArray: Boolean

Whether the KaType is an array or a primitive array type, and its element is also an array type.

isNothingType

abstract val KaType.isNothingType: Boolean

Whether the KaType is a Nothing type.

isNullable

abstract val KaType.isNullable: Boolean

Whether a public value of the KaType can potentially be null.

isPrimitive

abstract val KaType.isPrimitive: Boolean

Whether the KaType is a primitive type.

isPrimitiveBacked

Whether the given KaType is backed by a single JVM primitive type.

isResolveExtensionFile

abstract val VirtualFile.isResolveExtensionFile: Boolean

Whether the given VirtualFile is provided by a KaResolveExtension.

isShortType

abstract val KaType.isShortType: Boolean

Whether the KaType is a Short type.

isStableForSmartCasting

Whether this expression can be used as a stable smart-cast sink at the current program point.

isStringType

abstract val KaType.isStringType: Boolean

Whether the KaType is a String type.

isSuspendFunctionType

Whether the KaType is a suspend function type.

isUByteType

abstract val KaType.isUByteType: Boolean

Whether the KaType is a UByte type.

isUIntType

abstract val KaType.isUIntType: Boolean

Whether the KaType is a UInt type.

isULongType

abstract val KaType.isULongType: Boolean

Whether the KaType is a ULong type.

isUnitType

abstract val KaType.isUnitType: Boolean

Whether the KaType is a Unit type.

isUsedAsExpression

Whether the value of the given KtExpression is used. In other words, true if the value of the expression is not safe to discard.

isUsedAsResultOfLambda

Whether the value of the given KtExpression is used as the resulting expression of some lambda block.

isUShortType

abstract val KaType.isUShortType: Boolean

Whether the KaType is a UShort type.

klibSourceFileName

The source file name for the given KtDeclaration located in a Kotlin library (klib), or null if the declaration is not located in a klib, or when the source file name is not available.

memberScope

A KaScope containing non-static callable members (functions, properties, and constructors) and all classifier members (classes and objects) of the given KaDeclarationContainerSymbol. The scope includes members inherited from the symbol's supertypes, in addition to members which are declared explicitly inside the symbol's body.

namedClassSymbol

abstract val PsiClass.namedClassSymbol: KaNamedClassSymbol?

A KaNamedClassSymbol for the given PsiClass, or null for anonymous classes, local classes, type parameters (which are also PsiClasses), and Kotlin light classes.

A KaNamedClassSymbol for the given named KtClassOrObject, or null for KtEnumEntry declarations and object literals.

originalConstructorIfTypeAliased

packageScope

A KaScope containing all members of the package represented by the given KaPackageSymbol, not including members of subpackages.

receiverType

Resolves the given KtDoubleColonExpression to the KaType of its receiver.

resolveExtensionNavigationElements

A list of PsiElements which are used as navigation targets in place of this KtElement provided by a KaResolveExtension.

resolveExtensionScopeWithTopLevelDeclarations

The KaScope containing top-level callable declarations generated by KaResolveExtensions.

returnType

The return type of the given KtDeclarationWithReturnType.

returnValueStatus

The return value status of the function (should it be used, or can it be ignored). See the KEEP for details.

rootPackageSymbol

A KaPackageSymbol for the root package, which is the special package with an empty fully-qualified name.

samConstructor

scope

abstract val KaType.scope: KaTypeScope?

A KaTypeScope for the given KaType, or null if the type is erroneous. The scope includes all members which are callable on a given type. It also includes synthetic Java properties.

sealedClassInheritors

The inheritors of the given sealed class.

smartCastInfo

Smart cast information for the given KtExpression, or null if smart casts are not applied to it.

staticDeclaredMemberScope

A KaScope containing the static callables (functions and properties) and all classifiers (classes and objects) explicitly declared in the given KaDeclarationContainerSymbol.

staticMemberScope

A KaScope containing the static members of the given KaDeclarationContainerSymbol.

symbol

A KaVariableSymbol that corresponds to the local variable introduced by the given KtDestructuringDeclarationEntry.

abstract val KtFile.symbol: KaFileSymbol

A KaFileSymbol for a KtFile.

syntheticJavaPropertiesScope

A KaTypeScope containing the synthetic Java properties created for a given KaType.

token

abstract val token: KaLifetimeToken

The KaLifetimeToken which determines the lifetime of the lifetime owner.

type

abstract val KtTypeReference.type: KaType

Resolves the given KtTypeReference to its corresponding KaType.

typeCreator

abstract val typeCreator: KaTypeCreator

A single entry point for the type building infrastructure.

useSiteModule

abstract val useSiteModule: KaModule

The KaModule from whose perspective the analysis is performed. The use-site module defines the resolution scope of the KaSession, which signifies where symbols are located (such as sources, dependencies, and so on) and which symbols can be found in the first place.

useSiteSession

The KaSession of the current analysis context.

varargArrayType

The array type that represents the list of arguments passed to this parameter if this is a vararg parameter.

Functions

allSupertypes

abstract fun KaType.allSupertypes(shouldApproximate: Boolean): Sequence<KaType>

Returns all supertypes of the given KaType. The resulting sequence is ordered by a breadth-first traversal of the class hierarchy, without duplicates.

approximateToDenotableSubtype

Approximates KaType to a denotable subtype.

approximateToDenotableSubtypeOrSelf

Approximates KaType to a denotable subtype, or returns the given type itself if it is already denotable.

approximateToDenotableSupertype

abstract fun KaType.approximateToDenotableSupertype(allowLocalDenotableTypes: Boolean): KaType?

Approximates KaType to a denotable supertype.

Approximates KaType to a denotable supertype based on the given position.

approximateToDenotableSupertypeOrSelf

open fun KaType.approximateToDenotableSupertypeOrSelf(allowLocalDenotableTypes: Boolean): KaType

Approximates KaType to a denotable supertype, or returns the given type itself if it is already denotable.

Approximates KaType to a denotable subtype based on the given position, or returns the given type itself if it is already denotable.

asCompositeScope

Combines a list of KaScopes into a single composite KaScope. The resulting scope contains all members of its constituent scopes.

asKaType

abstract fun PsiType.asKaType(useSitePosition: PsiElement): KaType?

Converts the given PsiType to a KaType in the context of the useSitePosition.

asPsiType

abstract fun KaType.asPsiType(
    useSitePosition: PsiElement, 
    allowErrorTypes: Boolean, 
    mode: KaTypeMappingMode = KaTypeMappingMode.DEFAULT, 
    isAnnotationMethod: Boolean = false, 
    suppressWildcards: Boolean? = null, 
    preserveAnnotations: Boolean = true, 
    allowNonJvmPlatforms: Boolean = false
): PsiType?

Converts the given KaType to a PsiType in the context of the useSitePosition.

assertIsValidAndAccessible

asSignature

Creates a new KaCallableSignature for the given symbol and leaves all types unsubstituted.

Creates a new KaFunctionSignature for the given symbol and leaves all types unsubstituted.

Creates a new KaVariableSignature for the given symbol and leaves all types unsubstituted.

buildArrayType

abstract fun buildArrayType(elementType: KaType, init: KaArrayTypeBuilder.() -> Unit = {}): KaType

Builds a boxed / primitive (depending on the init block) array type from the given elementType.

buildClassType

abstract fun buildClassType(symbol: KaClassLikeSymbol, init: KaClassTypeBuilder.() -> Unit = {}): KaType

Builds a class type with the given class symbol.

abstract fun buildClassType(classId: ClassId, init: KaClassTypeBuilder.() -> Unit = {}): KaType

Builds a class type with the given class ID.

buildStarTypeProjection

buildTypeParameterType

Builds a KaTypeParameterType with the given type parameter symbol.

buildVarargArrayType

abstract fun buildVarargArrayType(elementType: KaType): KaType

Builds the underlying array type of vararg function parameter with the given elementType.

canBeAnalysed

abstract fun PsiElement.canBeAnalysed(): Boolean

Checks whether the PsiElement is inside the analysisScope.

collectCallCandidates

Returns all candidates considered during overload resolution for the call corresponding to the given KtResolvableCall.

collectDiagnostics

Collects all diagnostics for the given file.

collectPossibleReferenceShortenings

abstract fun collectPossibleReferenceShortenings(
    file: KtFile, 
    selection: TextRange = file.textRange, 
    shortenOptions: ShortenOptions = ShortenOptions.DEFAULT, 
    classShortenStrategy: (KaClassLikeSymbol) -> ShortenStrategy = defaultClassShortenStrategy, 
    callableShortenStrategy: (KaCallableSymbol) -> ShortenStrategy = defaultCallableShortenStrategy
): ShortenCommand

Collects possible references to shorten.

collectPossibleReferenceShorteningsInElement

abstract fun collectPossibleReferenceShorteningsInElement(
    element: KtElement, 
    shortenOptions: ShortenOptions = ShortenOptions.DEFAULT, 
    classShortenStrategy: (KaClassLikeSymbol) -> ShortenStrategy = defaultClassShortenStrategy, 
    callableShortenStrategy: (KaCallableSymbol) -> ShortenStrategy = defaultCallableShortenStrategy
): ShortenCommand

Collects possible references to shorten in elements text range.

compile

abstract fun compile(file: KtFile, options: KaCompilationOptions): KaCompilationResult

Compiles the given file in-memory using the specified options.

compositeScope

open fun KaScopeContext.compositeScope(filter: (KaScopeKind) -> Boolean = { true }): KaScope

Returns a single KaScope that contains declarations from all scopes that satisfy filter.

computeExitPointSnapshot

computeMissingCases

Computes the missing cases of the given KtWhenExpression.

copy

abstract fun <T : KaClassType> T.copy(init: KaClassTypeBuilder.() -> Unit): KaClassType

Creates a copy of this KaClassType with modifications applied via the init block.

Creates a copy of this KaFunctionType with modifications applied via the init block.

Creates a copy of this KaTypeParameterType with modifications applied via the init block.

Creates a copy of this KaUsualClassType with modifications applied via the init block.

createCompilationOptions

Creates a new KaCompilationOptions instance using the given DSL init block.

createExtensionCandidateChecker

abstract fun createExtensionCandidateChecker(
    originalFile: KtFile, 
    nameExpression: KtSimpleNameExpression, 
    explicitReceiver: KtExpression?
): KaCompletionExtensionCandidateChecker

Returns an extension applicability checker for the given context nameExpression. The function is meant to only be used for providing auto-completion for Kotlin in IntelliJ IDEA.

createInheritanceTypeSubstitutor

Creates a KaSubstitutor based on the inheritance relationship between subClass and superClass. subClass must inherit from superClass and there may not be any error types in the inheritance path. Otherwise, null is returned.

createSubstitutor

Creates a KaSubstitutor based on the given mappings.

createSubtypingUnificationSubstitutor

abstract fun createSubtypingUnificationSubstitutor(leftTypesToRightTypes: List<Pair<KaType, KaType>>, isFreeTypeParameter: (KaTypeParameterSymbol) -> Boolean): KaSubstitutor?

Creates a KaSubstitutor which assigns type arguments such that, for each pair in leftTypesToRightTypes, the substituted left type is a subtype of the substituted right type. Returns null if such an assignment is not possible.

abstract fun createSubtypingUnificationSubstitutor(leftTypesToRightTypes: List<Pair<KaType, KaType>>, constructionPolicy: KaUnificationSubstitutorPolicy): KaSubstitutor?

Creates a KaSubstitutor which assigns type arguments such that, for each pair in leftTypesToRightTypes, the substituted left type is a subtype of the substituted right type. Returns null if such an assignment is not possible.

abstract fun createSubtypingUnificationSubstitutor(
    leftType: KaType, 
    rightType: KaType, 
    constructionPolicy: KaUnificationSubstitutorPolicy
): KaSubstitutor?

Creates a KaSubstitutor which assigns type arguments such that the substituted leftType is a subtype of the substituted rightType. Returns null if such an assignment is not possible.

createUseSiteVisibilityChecker

abstract fun createUseSiteVisibilityChecker(
    useSiteFile: KaFileSymbol, 
    receiverExpression: KtExpression? = null, 
    position: PsiElement
): KaUseSiteVisibilityChecker

Creates a visibility checker for the given use-site position.

directSupertypes

abstract fun KaType.directSupertypes(shouldApproximate: Boolean): Sequence<KaType>

Returns the direct supertypes of the given KaType.

evaluate

Attempts to evaluate the given KtExpression to a compile-time constant value, or returns null if this is not possible.

evaluateAsAnnotationValue

Attempts to evaluate the given KtExpression to an annotation value (a constant value which can be used as an annotation argument), or returns null if this is not possible.

findClass

abstract fun findClass(classId: ClassId): KaClassSymbol?

Returns a KaClassSymbol for the specified ClassId, or null if such a symbol cannot be found.

findClassLike

abstract fun findClassLike(classId: ClassId): KaClassLikeSymbol?

Returns a KaClassLikeSymbol for the specified ClassId, or null if such a symbol cannot be found.

findKDoc

Resolves KDoc for this KaDeclarationSymbol.

Resolves KDoc for this KtDeclaration.

findPackage

abstract fun findPackage(fqName: FqName): KaPackageSymbol?

Returns a KaPackageSymbol corresponding to the given fqName if that package exists and is visible from the current use site, or null otherwise.

findTopLevelCallables

abstract fun findTopLevelCallables(packageFqName: FqName, name: Name): Sequence<KaCallableSymbol>

Finds top-level functions and properties called name in the package called packageFqName. Returns only symbols that are visible from the current use-site module.

findTypeAlias

abstract fun findTypeAlias(classId: ClassId): KaTypeAliasSymbol?

Returns a KaTypeAliasSymbol for the specified ClassId, or null if such a symbol cannot be found.

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.

hasCommonSubtypeWith

abstract fun KaType.hasCommonSubtypeWith(that: KaType): Boolean

Checks whether this KaType is compatible with that other type. If they are compatible, the types can have a common subtype.

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.

implementationState

isDirectSubClassOf

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

isPublicApi

abstract fun isPublicApi(symbol: KaDeclarationSymbol): Boolean

Whether the symbol is effectively public, including internal declarations with the PublishedApi annotation.

isSubClassOf

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

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

isSubtypeOf

abstract fun KaType.isSubtypeOf(symbol: KaClassLikeSymbol, errorTypePolicy: KaSubtypingErrorTypePolicy = KaSubtypingErrorTypePolicy.STRICT): Boolean

Returns whether this KaType is a subtype of a class represented by symbol.

abstract fun KaType.isSubtypeOf(supertype: KaType, errorTypePolicy: KaSubtypingErrorTypePolicy = KaSubtypingErrorTypePolicy.STRICT): Boolean

Returns whether this KaType is a subtype of supertype. The relation is non-strict, i.e. any type t is a subtype of itself.

abstract fun KaType.isSubtypeOf(classId: ClassId, errorTypePolicy: KaSubtypingErrorTypePolicy = KaSubtypingErrorTypePolicy.STRICT): Boolean

Returns whether this KaType is a subtype of a class called classId.

isValid

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

isVisibleInClass

Checks whether the given KaCallableSymbol (possibly inherited from a superclass) is visible in the given classSymbol.

lowerBoundIfFlexible

Returns the KaFlexibleType's lower bound, or the type itself if it is not flexible.

mapToJvmTypeDescriptor

Convert the given KaType to a JVM type descriptor with the KaTypeMappingMode.DEFAULT. To learn more about JVM descriptors, check out the JVM specification.

modify

Creates a copy of these KaCompilationOptions, applying the given init modifications.

render

abstract fun KaDeclarationSymbol.render(renderer: KaDeclarationRenderer = KaDeclarationRendererForSource.WITH_QUALIFIED_NAMES): String

Renders the given KaDeclarationSymbol to a string. The particular rendering strategy is defined by the renderer.

abstract fun KaType.render(renderer: KaTypeRenderer = KaTypeRendererForSource.WITH_QUALIFIED_NAMES, position: Variance): String

Renders the given KaType into a string. The particular rendering strategy is defined by the renderer.

resolveCall

Resolves the given KtAnnotationEntry to an annotation constructor call.

Resolves the given KtArrayAccessExpression to a simple function call representing get/set operator invocation.

Resolves the given KtCallElement to a function call.

Resolves the given KtCallableReferenceExpression to a callable member call.

Resolves the given KtCollectionLiteralExpression to a simple function call representing the corresponding array factory invocation.

Resolves the given KtConstructorDelegationCall to a delegated constructor call.

Resolves the given KtDestructuringDeclarationEntry to a call representing the componentN invocation (for positional destructuring) or the property access (for name-based destructuring).

Resolves the given KtForExpression to a KaForLoopCall representing the desugared for loop.

Resolves the given KtNameReferenceExpression to a call representing the referenced declaration.

Resolves the given KtPropertyDelegate to a KaDelegatedPropertyCall representing the desugared delegated property.

Resolves the given KtQualifiedExpression to a call representing the member or extension access.

Resolves the given KtSuperTypeCallEntry to a constructor call of the referenced supertype.

Resolves the given KtWhenConditionInRange to a simple function call representing the corresponding contains operator invocation used by the in/!in branch condition.

Resolves the call for the given KtResolvableCall.

resolveSymbol

Resolves the constructor symbol of the annotation referenced by the given KtAnnotationEntry.

Resolves the operator function symbol targeted by the given KtArrayAccessExpression.

Resolves the function symbol targeted by the given KtCallElement.

Resolves the callable symbol targeted by the given KtCallableReferenceExpression.

Resolves the classifier symbol referenced by the given KtClassLiteralExpression (Foo::class).

Resolves the function symbol targeted by the given KtCollectionLiteralExpression.

Resolves the constructor symbol referenced by the given KtConstructorCalleeExpression.

Resolves the constructor symbol referenced by the given KtConstructorDelegationCall.

Resolves the constructor symbol referenced by the given KtConstructorDelegationReferenceExpression.

Resolves the classifier symbol referenced by the given KtDelegatedSuperTypeEntry (class Foo : Bar by baz).

Resolves the callable symbol targeted by the given KtDestructuringDeclarationEntry.

Resolves the enum class symbol referenced by the given KtEnumEntrySuperclassReferenceExpression.

Resolves the synthetic function class symbol referenced by the given KtFunctionType.

Resolves the declaration symbol referenced by the given KtInstanceExpressionWithLabel.

Resolves the declaration symbol targeted by the given KtLabelReferenceExpression.

Resolves the classifier symbol referenced by the given KtNullableType.

Resolves the callable symbol targeted by the given KtQualifiedExpression.

Resolves the function symbol targeted by the given KtReturnExpression.

Resolves the constructor symbol by the given KtSuperTypeCallEntry.

Resolves the classifier symbol referenced by the given KtSuperTypeEntry (the no-parens form class Foo : Bar).

Resolves the classifier symbol referenced by the given KtTypeReference.

Resolves the operator function symbol targeted by the given KtWhenConditionInRange.

Resolves a single symbol for the given KtResolvable.

resolveSymbols

Resolves symbols for the given KtResolvable.

resolveToCall

Resolves the given KtElement to a KaCallInfo object. KaCallInfo either contains a successfully resolved call or an error with a list of candidate calls and a diagnostic.

resolveToCallCandidates

Returns all candidates considered during overload resolution for the call corresponding to this KtElement.

resolveToSymbol

Resolves the given KtReference to a symbol.

resolveToSymbols

Resolves the given KtReference to symbols.

restore

open fun <T : KaType> KaTypePointer<T>.restore(): T?

Returns the restored KaType (possibly a new type instance) if the pointer is still valid, or null otherwise.

restoreSymbol

Returns the restored KaSymbol (possibly a new symbol instance) if the pointer is still valid, or null otherwise.

scopeContext

abstract fun KtFile.scopeContext(position: KtElement): KaScopeContext

Computes the lexical scope context for a given position in the KtFile. The scope context includes all scopes that are relevant for the given position, together with all available implicit receivers.

semanticallyEquals

abstract fun KaType.semanticallyEquals(other: KaType, errorTypePolicy: KaSubtypingErrorTypePolicy = KaSubtypingErrorTypePolicy.STRICT): Boolean

Returns whether this KaType is semantically equal to other.

substitute

abstract fun <S : KaCallableSymbol> S.substitute(substitutor: KaSubstitutor): KaCallableSignature<S>

Applies a substitutor to the given symbol and returns a KaCallableSignature with substituted types.

abstract fun <S : KaFunctionSymbol> S.substitute(substitutor: KaSubstitutor): KaFunctionSignature<S>

Applies a substitutor to the given symbol and returns a KaFunctionSignature with substituted types.

abstract fun <S : KaVariableSymbol> S.substitute(substitutor: KaSubstitutor): KaVariableSignature<S>

Applies a substitutor to the given symbol and returns a KaVariableSignature with substituted types.

tryResolveCall

Attempts to resolve the given KtForExpression to a KaForLoopCallResolutionAttempt containing the individual resolution results for each desugared operator call (iterator, hasNext, next).

Attempts to resolve the given KtPropertyDelegate to a KaDelegatedPropertyCallResolutionAttempt containing the individual resolution results for each desugared operator call (getValue, setValue, provideDelegate).

Attempts to resolve the call for the given KtResolvableCall.

tryResolveSymbols

Attempts to resolve a symbol for the given KtResolvable.

upperBoundIfFlexible

Returns the KaFlexibleType's upper bound, or the type itself if it is not flexible.

withNullability

abstract fun KaType.withNullability(isMarkedNullable: Boolean): KaType

Creates a new KaType based on the given type with the updated nullability specified by isMarkedNullable.

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.