Skip to main content

Default Arguments

Enabled (Boolean)

Controls whether the default arguments feature is enabled or disabled.

The default value is false.

Annotation configuration:

Kotlin
import co.touchlab.skie.configuration.annotations.DefaultArgumentInterop

@DefaultArgumentInterop.Enabled
fun enabled(i: Int = 0) {
}

@DefaultArgumentInterop.Disabled
fun disabled(i: Int = 0) {
}

Gradle configuration:

build.gradle.kts
import co.touchlab.skie.configuration.DefaultArgumentInterop

skie {
features {
group {
DefaultArgumentInterop.Enabled(true) // or false
}
}
}

MaximumDefaultArgumentCount (Int)

Specifies the maximum number of default arguments that can be used in a single function. SKIE will not generate overloads for functions that have more default arguments than this value.

danger

The number of generated overloads is O(2^n), where n is the number of default arguments in the given function. Setting this value too high will result in significantly increased compilation time. And from a certain point, the project will not compile due to the compiler running out of memory.

note

This limit applies even if the default arguments feature is otherwise enabled for the given function.

The default value is 5.

Annotation configuration:

Kotlin
import co.touchlab.skie.configuration.annotations.DefaultArgumentInterop

@DefaultArgumentInterop.MaximumDefaultArgumentCount(6)
fun functionWithSixDefaultArguments(p1: Int = 0, p2: Int = 0, p3: Int = 0, p4: Int = 0, p5: Int = 0, p6: Int = 0) {
}

Gradle configuration:

build.gradle.kts
import co.touchlab.skie.configuration.DefaultArgumentInterop

skie {
features {
group {
DefaultArgumentInterop.MaximumDefaultArgumentCount(6)
}
}
}

DefaultArgumentsInExternalLibraries (Boolean)

Controls whether the default arguments feature is allowed for functions from external libraries.

caution

Setting this property to true disables Kotlin native compiler caching. This can lead to a significant increase in compilation time.

note

Even with this property turned on, it is still required to enable default arguments for individual functions from those libraries. You will most likely need to use the Gradle configuration for this.

The default value is false.

Gradle configuration:

build.gradle.kts
skie {
features {
defaultArgumentsInExternalLibraries.set(true) // or false
}
}