Skip to content

KaCompilationOptionsBuilder

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 createCompilationOptions and modify.

See also

Inheritors

Properties

token

abstract val token: KaLifetimeToken

The KaLifetimeToken which determines the lifetime of the lifetime owner.

Functions

allowedErrorFilter

abstract 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 fun codeFragmentClassName(value: String)

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

codeFragmentMethodName

abstract fun codeFragmentMethodName(value: String)

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

disableCallAssertions

abstract fun disableCallAssertions(value: Boolean)

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

disableInline

abstract fun disableInline(value: Boolean)

Disables inlining of inline functions.

disableOptimization

abstract fun disableOptimization(value: Boolean)

Disables optimizations in generated code.

disableParameterAssertions

abstract 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.

See also

jvmExecutionStack

abstract 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 fun jvmGenerateParameterMetadata(value: Boolean)

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

jvmOutputAsmListing

abstract fun jvmOutputAsmListing(value: Boolean)

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

jvmTarget

abstract fun jvmTarget(value: KaJvmTarget)

Sets the JVM bytecode target version.

jvmUseInvokeDynamicForLambdas

abstract fun jvmUseInvokeDynamicForLambdas(value: Boolean)

Uses invokedynamic for lambdas instead of generating anonymous classes.

jvmUseInvokeDynamicForSamConversions

Uses invokedynamic for SAM conversions instead of generating anonymous classes.

languageVersionSettings

abstract fun languageVersionSettings(value: LanguageVersionSettings)

Sets the language version settings used during compilation.

moduleActualizer

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

See also

moduleName

abstract fun moduleName(value: String)

Sets the module name used for the compiled output.

stubUnboundIrSymbols

abstract 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.

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.