Skip to content

KaCompilationOptionsBuilder

The type has been moved to a new package. Use <strong>org.jetbrains.kotlin.analysis.api.compilation.KaCompilationOptionsBuilder</strong> instead.

A DSL builder for KaCompilationOptions.

Provides methods to configure the compilation target, language settings, JVM-specific options, error handling, and code fragment parameters. Instances are created internally by KaCompilerFacility.createCompilationOptions and KaCompilerFacility.modify.

See also

Properties

token

abstract val token: KaLifetimeToken

The KaLifetimeToken which determines the lifetime of the lifetime owner.

Functions

allowedErrorFilter

abstract override fun allowedErrorFilter(value: (KaDiagnostic) -> Boolean)

Sets a filter for allowed errors. Compilation will be aborted if there are errors that this filter rejects.

A filter returning true means the error is allowed and will not abort compilation. Defaults to rejecting all errors.

assertIsValidAndAccessible

codeFragmentClassName

abstract override fun codeFragmentClassName(value: String)

Sets the simple class name for the code fragment facade class. Only relevant when compiling KtCodeFragment files.

codeFragmentMethodName

abstract override fun codeFragmentMethodName(value: String)

Sets the entry point method name for the code fragment. Only relevant when compiling KtCodeFragment files.

disableCallAssertions

abstract override fun disableCallAssertions(value: Boolean)

Disables null-check assertions on receiver and arguments of platform-typed calls.

disableInline

abstract override fun disableInline(value: Boolean)

Disables inlining of inline functions.

disableOptimization

abstract override fun disableOptimization(value: Boolean)

Disables optimizations in generated code.

disableParameterAssertions

abstract override fun disableParameterAssertions(value: Boolean)

Disables null-check assertions on parameters.

isValid

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

jvmCompiledClassHandler

Sets a handler which is called whenever a new class file is produced.

Sets a handler which is called whenever a new class file is produced.

jvmExecutionStack

abstract override fun jvmExecutionStack(value: Sequence<PsiElement?>)

Sets the execution stack for debugger code fragment compilation.

A sequence of PSI elements representing function calls or property accesses in the current execution stack, listed from the top to the bottom.

jvmGenerateParameterMetadata

abstract override fun jvmGenerateParameterMetadata(value: Boolean)

Enables generation of parameter metadata (names and access flags) in class files.

jvmOutputAsmListing

abstract override fun jvmOutputAsmListing(value: Boolean)

Enables output of ASM bytecode listing. When true, selects the test-mode class builder factory.

jvmTarget

abstract override fun jvmTarget(value: KaJvmTarget)

Sets the JVM bytecode target version.

jvmUseInvokeDynamicForLambdas

abstract override fun jvmUseInvokeDynamicForLambdas(value: Boolean)

Uses invokedynamic for lambdas instead of generating anonymous classes.

jvmUseInvokeDynamicForSamConversions

abstract override fun jvmUseInvokeDynamicForSamConversions(value: Boolean)

Uses invokedynamic for SAM conversions instead of generating anonymous classes.

languageVersionSettings

abstract override fun languageVersionSettings(value: LanguageVersionSettings)

Sets the language version settings used during compilation.

moduleActualizer

Sets a custom actualizer for common source modules in multiplatform projects.

Sets a custom actualizer for common source modules in multiplatform projects.

moduleName

abstract override fun moduleName(value: String)

Sets the module name used for the compiled output.

stubUnboundIrSymbols

abstract override fun stubUnboundIrSymbols(value: Boolean)

Whether unbound IR symbols should be stubbed instead of linked.

This should be enabled if the compiled file could refer to symbols defined in another file of the same module.

target

abstract fun target(value: KaCompilationTarget)

Sets the target platform for compilation. Must be provided.

abstract fun target(value: KaCompilationTarget)

Sets the target platform for compilation. Must be provided.

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.