Skip to content

Commit c2b9fbd

Browse files
committed
Working prototype that builds against guava
1 parent 0c963b0 commit c2b9fbd

File tree

5 files changed

+25
-26
lines changed

5 files changed

+25
-26
lines changed

compiler/build-tools/kotlin-build-tools-api/api/kotlin-build-tools-api.api

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ public final class org/jetbrains/kotlin/buildtools/api/SourcesChanges$Unknown :
154154
public abstract interface class org/jetbrains/kotlin/buildtools/api/arguments/CommonCompilerArguments : org/jetbrains/kotlin/buildtools/api/arguments/CommonToolArguments {
155155
public static final field API_VERSION Lorg/jetbrains/kotlin/buildtools/api/arguments/CommonCompilerArguments$CommonCompilerArgument;
156156
public static final field Companion Lorg/jetbrains/kotlin/buildtools/api/arguments/CommonCompilerArguments$Companion;
157+
public static final field HEADER Lorg/jetbrains/kotlin/buildtools/api/arguments/CommonCompilerArguments$CommonCompilerArgument;
157158
public static final field KOTLIN_HOME Lorg/jetbrains/kotlin/buildtools/api/arguments/CommonCompilerArguments$CommonCompilerArgument;
158159
public static final field LANGUAGE_VERSION Lorg/jetbrains/kotlin/buildtools/api/arguments/CommonCompilerArguments$CommonCompilerArgument;
159160
public static final field OPT_IN Lorg/jetbrains/kotlin/buildtools/api/arguments/CommonCompilerArguments$CommonCompilerArgument;

compiler/build-tools/kotlin-build-tools-compat/gen/org/jetbrains/kotlin/buildtools/internal/compat/arguments/CommonCompilerArgumentsImpl.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import kotlin.collections.MutableMap
1616
import kotlin.collections.mutableListOf
1717
import kotlin.collections.mutableMapOf
1818
import org.jetbrains.kotlin.buildtools.api.arguments.CommonCompilerArguments.Companion.API_VERSION
19+
import org.jetbrains.kotlin.buildtools.api.arguments.CommonCompilerArguments.Companion.HEADER
1920
import org.jetbrains.kotlin.buildtools.api.arguments.CommonCompilerArguments.Companion.KOTLIN_HOME
2021
import org.jetbrains.kotlin.buildtools.api.arguments.CommonCompilerArguments.Companion.LANGUAGE_VERSION
2122
import org.jetbrains.kotlin.buildtools.api.arguments.CommonCompilerArguments.Companion.OPT_IN
@@ -125,6 +126,7 @@ internal open class CommonCompilerArgumentsImpl : CommonToolArgumentsImpl(),
125126
if ("LANGUAGE_VERSION" in optionsMap) { arguments.add("-language-version=" + get(LANGUAGE_VERSION)?.stringValue) }
126127
if ("API_VERSION" in optionsMap) { arguments.add("-api-version=" + get(API_VERSION)?.stringValue) }
127128
if ("KOTLIN_HOME" in optionsMap) { arguments.add("-kotlin-home=" + get(KOTLIN_HOME)) }
129+
if ("HEADER" in optionsMap) { arguments.add("-header=" + get(HEADER)) }
128130
if ("PROGRESSIVE" in optionsMap) { arguments.add("-progressive=" + get(PROGRESSIVE)) }
129131
if ("OPT_IN" in optionsMap) { arguments.add("-opt-in=" + get(OPT_IN)) }
130132
if ("X_NO_INLINE" in optionsMap) { arguments.add("-Xno-inline=" + get(X_NO_INLINE)) }
@@ -198,6 +200,7 @@ internal open class CommonCompilerArgumentsImpl : CommonToolArgumentsImpl(),
198200
this[LANGUAGE_VERSION] = arguments.languageVersion?.let { KotlinVersion.valueOf(it) }
199201
this[API_VERSION] = arguments.apiVersion?.let { KotlinVersion.valueOf(it) }
200202
this[KOTLIN_HOME] = arguments.kotlinHome
203+
this[HEADER] = arguments.headerMode
201204
this[PROGRESSIVE] = arguments.progressiveMode
202205
this[OPT_IN] = arguments.optIn
203206
this[X_NO_INLINE] = arguments.noInline
@@ -277,6 +280,8 @@ internal open class CommonCompilerArgumentsImpl : CommonToolArgumentsImpl(),
277280

278281
public val KOTLIN_HOME: CommonCompilerArgument<String?> = CommonCompilerArgument("KOTLIN_HOME")
279282

283+
public val HEADER: CommonCompilerArgument<Boolean> = CommonCompilerArgument("HEADER")
284+
280285
public val PROGRESSIVE: CommonCompilerArgument<Boolean> = CommonCompilerArgument("PROGRESSIVE")
281286

282287
public val OPT_IN: CommonCompilerArgument<Array<String>?> = CommonCompilerArgument("OPT_IN")

compiler/build-tools/kotlin-build-tools-impl/gen/org/jetbrains/kotlin/buildtools/internal/arguments/CommonCompilerArgumentsImpl.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ internal open class CommonCompilerArgumentsImpl : CommonToolArgumentsImpl(),
203203
if ("LANGUAGE_VERSION" in optionsMap) { arguments.add("-language-version=" + get(LANGUAGE_VERSION)?.stringValue) }
204204
if ("API_VERSION" in optionsMap) { arguments.add("-api-version=" + get(API_VERSION)?.stringValue) }
205205
if ("KOTLIN_HOME" in optionsMap) { arguments.add("-kotlin-home=" + get(KOTLIN_HOME)) }
206+
if ("HEADER" in optionsMap) { arguments.add("-header=" + get(HEADER)) }
206207
if ("PROGRESSIVE" in optionsMap) { arguments.add("-progressive=" + get(PROGRESSIVE)) }
207208
if ("OPT_IN" in optionsMap) { arguments.add("-opt-in=" + get(OPT_IN)) }
208209
if ("X_NO_INLINE" in optionsMap) { arguments.add("-Xno-inline=" + get(X_NO_INLINE)) }
@@ -276,6 +277,7 @@ internal open class CommonCompilerArgumentsImpl : CommonToolArgumentsImpl(),
276277
this[LANGUAGE_VERSION] = arguments.languageVersion?.let { KotlinVersion.valueOf(it) }
277278
this[API_VERSION] = arguments.apiVersion?.let { KotlinVersion.valueOf(it) }
278279
this[KOTLIN_HOME] = arguments.kotlinHome
280+
this[HEADER] = arguments.headerMode
279281
this[PROGRESSIVE] = arguments.progressiveMode
280282
this[OPT_IN] = arguments.optIn
281283
this[X_NO_INLINE] = arguments.noInline

compiler/cli/src/org/jetbrains/kotlin/cli/common/klibArguments.kt

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,6 @@ import org.jetbrains.kotlin.config.zipFileSystemAccessor
1616
import org.jetbrains.kotlin.konan.file.ZipFileSystemAccessor
1717
import org.jetbrains.kotlin.konan.file.ZipFileSystemCacheableAccessor
1818
import org.jetbrains.kotlin.konan.file.ZipFileSystemInPlaceAccessor
19-
import org.jetbrains.kotlin.config.CompilerConfiguration
20-
import org.jetbrains.kotlin.config.DuplicatedUniqueNameStrategy
21-
import org.jetbrains.kotlin.config.KlibAbiCompatibilityLevel
22-
import org.jetbrains.kotlin.config.LanguageFeature
23-
import org.jetbrains.kotlin.config.LanguageVersion
24-
import org.jetbrains.kotlin.config.customKlibAbiVersion
25-
import org.jetbrains.kotlin.config.duplicatedUniqueNameStrategy
26-
import org.jetbrains.kotlin.config.headerCompilation
27-
import org.jetbrains.kotlin.config.klibAbiCompatibilityLevel
28-
import org.jetbrains.kotlin.config.klibNormalizeAbsolutePath
29-
import org.jetbrains.kotlin.config.klibRelativePathBases
30-
import org.jetbrains.kotlin.config.messageCollector
31-
import org.jetbrains.kotlin.config.produceKlibSignaturesClashChecks
3219
import org.jetbrains.kotlin.library.KotlinAbiVersion
3320
import java.util.EnumMap
3421
import kotlin.collections.plus

compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/LightTreeRawFirDeclarationBuilder.kt

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1254,12 +1254,8 @@ class LightTreeRawFirDeclarationBuilder(
12541254
typeParameters += constructorTypeParametersFromConstructedClass(classWrapper.classBuilder.typeParameters)
12551255
valueParameters += firValueParameters.map { it.firValueParameter }
12561256
// TODO-HEADER-COMPILATION: Potentially remove this and produce an empty constructor body.
1257-
val (body, contractDescription) = if (headerCompilationMode) {
1258-
buildEmptyExpressionBlock() to null
1259-
} else {
1260-
withForcedLocalContext {
1261-
convertFunctionBody(block, null, allowLegacyContractDescription = true)
1262-
}
1257+
val (body, contractDescription) = withForcedLocalContext {
1258+
convertFunctionBody(block, null, allowLegacyContractDescription = true)
12631259
}
12641260
this.body = body
12651261
contractDescription?.let { this.contractDescription = it }
@@ -1780,12 +1776,11 @@ class LightTreeRawFirDeclarationBuilder(
17801776
}
17811777
val allowLegacyContractDescription = outerContractDescription == null
17821778
// TODO-HEADER-COMPILATION: Potentially remove getter/setter code.
1783-
val bodyWithContractDescription = if (headerCompilationMode) {
1784-
buildEmptyExpressionBlock() to null
1785-
} else {
1786-
withForcedLocalContext {
1787-
convertFunctionBody(block, expression, allowLegacyContractDescription)
1788-
}
1779+
// (headerCompilationMode) {
1780+
// buildEmptyExpressionBlock() to null
1781+
// }
1782+
val bodyWithContractDescription = withForcedLocalContext {
1783+
convertFunctionBody(block, expression, allowLegacyContractDescription)
17891784
}
17901785
this.body = bodyWithContractDescription.first
17911786
val contractDescription = outerContractDescription ?: bodyWithContractDescription.second
@@ -2001,11 +1996,18 @@ class LightTreeRawFirDeclarationBuilder(
20011996
else implicitType
20021997
}
20031998

1999+
// TODO-HEADER-COMPILE: While it's a good idea to try to avoid
2000+
// producing private functions, this breaks when the function is
2001+
// decorated with @JvmStatic since it makes it visible to Java
2002+
// programs and causes symbol not found errors.
2003+
// Fix would be to check if the annotation is there and then skip.
2004+
/*
20042005
if (headerCompilationMode) {
20052006
if (calculatedModifiers.getVisibility() == Visibilities.Private) {
20062007
return null
20072008
}
20082009
}
2010+
*/
20092011

20102012
val receiverTypeCalculator = receiverTypeNode?.let { { convertType(it) } }
20112013
val functionBuilder = if (isAnonymousFunction) {
@@ -2124,7 +2126,9 @@ class LightTreeRawFirDeclarationBuilder(
21242126
}
21252127
) to null)
21262128

2127-
val bodyWithContractDescription = if (headerCompilationMode) {
2129+
// Block is null when you have an interface or abstract function declaration.
2130+
// In such cases, for header compile mode you shall not generate any code either.
2131+
val bodyWithContractDescription = if (headerCompilationMode && block != null) {
21282132
buildReturnNullExclExclBlock()
21292133
} else {
21302134
withForcedLocalContext {

0 commit comments

Comments
 (0)