Skip to content
Open

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions compiler/arguments/resources/kotlin-compiler-arguments.json
Original file line number Diff line number Diff line change
Expand Up @@ -2271,6 +2271,37 @@
"removedVersion": null
}
},
{
"name": "Xheader-mode",
"shortName": null,
"deprecatedName": null,
"description": {
"current": "Enable header compilation mode.\nIn this mode, the compiler produces class files that only contain the 'skeleton' of the classes to be\ncompiled but the method bodies of all the implementations are empty. This is used to speed up parallel compilation\nbuild systems where header libraries can be used to replace downstream dependencies for which we only need to\nsee the type names and method signatures required to compile a given translation unit. Inline functions are still kept\nwith bodies.",
"valueInVersions": []
},
"delimiter": null,
"valueType": {
"type": "org.jetbrains.kotlin.arguments.dsl.types.BooleanType",
"isNullable": {
"current": false,
"valueInVersions": []
},
"defaultValue": {
"current": false,
"valueInVersions": []
}
},
"valueDescription": {
"current": null,
"valueInVersions": []
},
"releaseVersionsMetadata": {
"introducedVersion": "2.3.0",
"stabilizedVersion": null,
"deprecatedVersion": null,
"removedVersion": null
}
},
{
"name": "Xignore-const-optimization-errors",
"shortName": null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1167,4 +1167,21 @@ Warning: this flag is not intended for production use. If you want to configure
introducedVersion = KotlinReleaseVersion.v1_0_0
)
}

compilerArgument {
name = "Xheader-mode"
description = """
Enable header compilation mode.
In this mode, the compiler produces class files that only contain the 'skeleton' of the classes to be
compiled but the method bodies of all the implementations are empty. This is used to speed up parallel compilation
build systems where header libraries can be used to replace downstream dependencies for which we only need to
see the type names and method signatures required to compile a given translation unit. Inline functions are still kept
with bodies.
""".trimIndent().asReleaseDependent()
valueType = BooleanType.defaultFalse

lifecycle(
introducedVersion = KotlinReleaseVersion.v2_3_0
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,21 @@ public interface CommonCompilerArguments : CommonToolArguments {
public val X_FRAGMENT_FRIEND_DEPENDENCY: CommonCompilerArgument<Array<String>?> =
CommonCompilerArgument("X_FRAGMENT_FRIEND_DEPENDENCY", KotlinReleaseVersion(2, 3, 0))

/**
* Enable header compilation mode.
* In this mode, the compiler produces class files that only contain the 'skeleton' of the classes to be
* compiled but the method bodies of all the implementations are empty. This is used to speed up parallel compilation
* build systems where header libraries can be used to replace downstream dependencies for which we only need to
* see the type names and method signatures required to compile a given translation unit. Inline functions are still kept
* with bodies.
*
* WARNING: this option is EXPERIMENTAL and it may be changed in the future without notice or may be removed entirely.
*/
@JvmField
@ExperimentalCompilerArgument
public val X_HEADER_MODE: CommonCompilerArgument<Boolean> =
CommonCompilerArgument("X_HEADER_MODE", KotlinReleaseVersion(2, 3, 0))

/**
* Ignore all compilation exceptions while optimizing some constant expressions.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ import org.jetbrains.kotlin.buildtools.`internal`.arguments.CommonCompilerArgume
import org.jetbrains.kotlin.buildtools.`internal`.arguments.CommonCompilerArgumentsImpl.Companion.X_FRAGMENT_FRIEND_DEPENDENCY
import org.jetbrains.kotlin.buildtools.`internal`.arguments.CommonCompilerArgumentsImpl.Companion.X_FRAGMENT_REFINES
import org.jetbrains.kotlin.buildtools.`internal`.arguments.CommonCompilerArgumentsImpl.Companion.X_FRAGMENT_SOURCES
import org.jetbrains.kotlin.buildtools.`internal`.arguments.CommonCompilerArgumentsImpl.Companion.X_HEADER_MODE
import org.jetbrains.kotlin.buildtools.`internal`.arguments.CommonCompilerArgumentsImpl.Companion.X_IGNORE_CONST_OPTIMIZATION_ERRORS
import org.jetbrains.kotlin.buildtools.`internal`.arguments.CommonCompilerArgumentsImpl.Companion.X_INLINE_CLASSES
import org.jetbrains.kotlin.buildtools.`internal`.arguments.CommonCompilerArgumentsImpl.Companion.X_INTELLIJ_PLUGIN_ROOT
Expand Down Expand Up @@ -193,6 +194,7 @@ internal abstract class CommonCompilerArgumentsImpl : CommonToolArgumentsImpl(),
if (X_FRAGMENT_REFINES in this) { arguments.fragmentRefines = get(X_FRAGMENT_REFINES)}
if (X_FRAGMENT_SOURCES in this) { arguments.fragmentSources = get(X_FRAGMENT_SOURCES)}
if (X_FRAGMENTS in this) { arguments.fragments = get(X_FRAGMENTS)}
if (X_HEADER_MODE in this) { arguments.headerMode = get(X_HEADER_MODE)}
if (X_IGNORE_CONST_OPTIMIZATION_ERRORS in this) { arguments.ignoreConstOptimizationErrors = get(X_IGNORE_CONST_OPTIMIZATION_ERRORS)}
if (X_INLINE_CLASSES in this) { arguments.inlineClasses = get(X_INLINE_CLASSES)}
if (X_INTELLIJ_PLUGIN_ROOT in this) { arguments.intellijPluginRoot = get(X_INTELLIJ_PLUGIN_ROOT)}
Expand Down Expand Up @@ -290,6 +292,7 @@ internal abstract class CommonCompilerArgumentsImpl : CommonToolArgumentsImpl(),
try { this[X_FRAGMENT_REFINES] = arguments.fragmentRefines } catch (_: NoSuchMethodError) { }
try { this[X_FRAGMENT_SOURCES] = arguments.fragmentSources } catch (_: NoSuchMethodError) { }
try { this[X_FRAGMENTS] = arguments.fragments } catch (_: NoSuchMethodError) { }
try { this[X_HEADER_MODE] = arguments.headerMode } catch (_: NoSuchMethodError) { }
try { this[X_IGNORE_CONST_OPTIMIZATION_ERRORS] = arguments.ignoreConstOptimizationErrors } catch (_: NoSuchMethodError) { }
try { this[X_INLINE_CLASSES] = arguments.inlineClasses } catch (_: NoSuchMethodError) { }
try { this[X_INTELLIJ_PLUGIN_ROOT] = arguments.intellijPluginRoot } catch (_: NoSuchMethodError) { }
Expand Down Expand Up @@ -472,6 +475,9 @@ internal abstract class CommonCompilerArgumentsImpl : CommonToolArgumentsImpl(),
public val X_FRAGMENTS: CommonCompilerArgument<Array<String>?> =
CommonCompilerArgument("X_FRAGMENTS")

public val X_HEADER_MODE: CommonCompilerArgument<Boolean> =
CommonCompilerArgument("X_HEADER_MODE")

public val X_IGNORE_CONST_OPTIMIZATION_ERRORS: CommonCompilerArgument<Boolean> =
CommonCompilerArgument("X_IGNORE_CONST_OPTIMIZATION_ERRORS")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,21 @@ The argument should be used only if the new compilation scheme is enabled with -
field = value
}

@Argument(
value = "-Xheader-mode",
description = """Enable header compilation mode.
In this mode, the compiler produces class files that only contain the 'skeleton' of the classes to be
compiled but the method bodies of all the implementations are empty. This is used to speed up parallel compilation
build systems where header libraries can be used to replace downstream dependencies for which we only need to
see the type names and method signatures required to compile a given translation unit. Inline functions are still kept
with bodies.""",
)
var headerMode: Boolean = false
set(value) {
checkFrozen()
field = value
}

@Argument(
value = "-Xignore-const-optimization-errors",
description = "Ignore all compilation exceptions while optimizing some constant expressions.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ fun copyCommonCompilerArguments(from: CommonCompilerArguments, to: CommonCompile
to.fragmentRefines = from.fragmentRefines?.copyOf()
to.fragmentSources = from.fragmentSources?.copyOf()
to.fragments = from.fragments?.copyOf()
to.headerMode = from.headerMode
to.ignoreConstOptimizationErrors = from.ignoreConstOptimizationErrors
to.incrementalCompilation = from.incrementalCompilation
to.inlineClasses = from.inlineClasses
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ open class CommonCompilerArgumentsConfigurator {
put(AnalysisFlags.allowFullyQualifiedNameInKClass, true)
put(AnalysisFlags.dontWarnOnErrorSuppression, dontWarnOnErrorSuppression)
put(AnalysisFlags.lenientMode, lenientMode)
put(AnalysisFlags.headerMode, headerMode)
put(AnalysisFlags.hierarchicalMultiplatformCompilation, separateKmpCompilationScheme && multiPlatform)
fillWarningLevelMap(arguments, collector)
ReturnValueCheckerMode.fromString(returnValueChecker)?.also { put(AnalysisFlags.returnValueCheckerMode, it) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ object AnalysisFlags {
val lenientMode by AnalysisFlag.Delegates.Boolean

val hierarchicalMultiplatformCompilation by AnalysisFlag.Delegates.Boolean(defaultValue = false)

val headerMode by AnalysisFlag.Delegates.Boolean
}

@Deprecated(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
FILE: classDeclaration.kt
public final class A : R|kotlin/Any| {
public constructor(): R|A| {
super<R|kotlin/Any|>()
}

public final fun funA(): R|kotlin/String|

public final inline fun funB(): R|kotlin/String| {
^funB String(A.funB body)
}

@R|kotlin/OptIn|(markerClass = vararg(<getClass>(Q|kotlin/contracts/ExperimentalContracts|))) public final fun isNotNull(value: R|kotlin/Any?|): R|kotlin/Boolean|
[R|Contract description]
<
Returns(TRUE) -> value != null
>


private final fun funC(): R|kotlin/String|

public final fun funD(): R|kotlin/Int|

}
public abstract interface B : R|kotlin/Any| {
public open fun funA(): R|kotlin/String|

public abstract fun funB(): R|kotlin/String|

}
public final class C : R|B| {
public constructor(): R|C| {
super<R|kotlin/Any|>()
}

public open override fun funB(): R|kotlin/String|

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// RUN_PIPELINE_TILL: BACKEND
// FIR_DUMP
import kotlin.contracts.ExperimentalContracts
import kotlin.contracts.contract

class A {
fun funA(): String {
return "A.funA body"
}

inline fun funB(): String {
return "A.funB body"
}

@OptIn(ExperimentalContracts::class)
fun isNotNull(value: Any?): Boolean {
contract {
returns(true) implies (value != null)
}
return value != null
}

private fun funC(): String {
return "A.funC body"
}

fun funD() = 1 + 2
}

interface B {
fun funA(): String {
"B.funA body"
}

fun funB(): String
}

class C: B {
override fun funB(): String {
return "C.funB body"
}
}

/* GENERATED_FIR_TAGS: classDeclaration, classReference, contractConditionalEffect, contracts, functionDeclaration,
inline, interfaceDeclaration, nullableType, override, stringLiteral */
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FILE: functionDeclaration.kt
public final fun funA(): R|kotlin/String|
public final inline fun funB(): R|kotlin/String| {
^funB String(funB body)
}
@R|kotlin/OptIn|(markerClass = vararg(<getClass>(Q|kotlin/contracts/ExperimentalContracts|))) public final fun isNotNull(value: R|kotlin/Any?|): R|kotlin/Boolean|
[R|Contract description]
<
Returns(TRUE) -> value != null
>

private final fun funC(): R|kotlin/String|
public final fun funD(): R|kotlin/Int|
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// RUN_PIPELINE_TILL: BACKEND
// FIR_DUMP
import kotlin.contracts.ExperimentalContracts
import kotlin.contracts.contract

fun funA(): String {
return "funA body"
}

inline fun funB: String {
return "funB body"
}

@OptIn(ExperimentalContracts::class)
fun isNotNull(value: Any?): Boolean {
contract {
returns(true) implies (value != null)
}
return value != null
}

private fun funC(): String {
return "funC body"
}

fun funD() = 1 + 2

/* GENERATED_FIR_TAGS: classReference, contractConditionalEffect, contracts, functionDeclaration, inline, nullableType,
stringLiteral */
Loading