mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-05 15:53:13 +00:00
Compare commits
41 Commits
build-1.3.
...
FIR/invoke
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
75ae076c61 | ||
|
|
420f5c0c12 | ||
|
|
735c2a1c92 | ||
|
|
7c617718a7 | ||
|
|
70a852f072 | ||
|
|
bce20ea3e1 | ||
|
|
d90749709e | ||
|
|
106ab769dd | ||
|
|
02c90d0690 | ||
|
|
0458f94cdc | ||
|
|
6888499081 | ||
|
|
ee6da3964a | ||
|
|
b312edad09 | ||
|
|
e73dd86472 | ||
|
|
d046c4f94d | ||
|
|
bff89230a5 | ||
|
|
b4d4f91255 | ||
|
|
81faf01672 | ||
|
|
3eebe73291 | ||
|
|
fa0dcddff8 | ||
|
|
58d3178bea | ||
|
|
997d73b1ce | ||
|
|
d72f04455b | ||
|
|
b63d9b03af | ||
|
|
4fdff4fbd3 | ||
|
|
f4d00b6574 | ||
|
|
df1460c93b | ||
|
|
309dd87567 | ||
|
|
79b713cc75 | ||
|
|
1cf60b8c37 | ||
|
|
d0358a57c0 | ||
|
|
332cdbf5a7 | ||
|
|
bdfa82b010 | ||
|
|
8b4c1f6b57 | ||
|
|
eed465ae03 | ||
|
|
809b8a95b7 | ||
|
|
70ef431227 | ||
|
|
c3eea13f78 | ||
|
|
bdf7f65f13 | ||
|
|
2e1a8741cd | ||
|
|
fee05d20fe |
10
.idea/artifacts/dist.xml
generated
10
.idea/artifacts/dist.xml
generated
@@ -8,16 +8,16 @@
|
||||
</element>
|
||||
</element>
|
||||
<element id="file-copy" path="$PROJECT_DIR$/build/build.txt" />
|
||||
<element id="file-copy" path="$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-minimal-for-test/1.3.50-dev-526/7c531c6c6db03b6ebf0ff0e15027bb6aee5d2452/kotlin-stdlib-minimal-for-test-1.3.50-dev-526.jar" output-file-name="kotlin-stdlib-minimal-for-test.jar" />
|
||||
<element id="file-copy" path="$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-minimal-for-test/1.3.50-dev-397/9537914625d42146d9ebdd50cc7427c1116958dd/kotlin-stdlib-minimal-for-test-1.3.50-dev-397.jar" output-file-name="kotlin-stdlib-minimal-for-test.jar" />
|
||||
<element id="directory" name="common">
|
||||
<element id="file-copy" path="$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.3.50-dev-526/7a06077a97c805bc4d99aaa17c8e8accf86bfe7c/kotlin-stdlib-common-1.3.50-dev-526.jar" output-file-name="kotlin-stdlib-common.jar" />
|
||||
<element id="file-copy" path="$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.3.50-dev-526/784cfd305e170c525b1a6987584dd8bebc4e0e6a/kotlin-stdlib-common-1.3.50-dev-526-sources.jar" output-file-name="kotlin-stdlib-common-sources.jar" />
|
||||
<element id="file-copy" path="$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.3.50-dev-397/41d9c6981aea1e2b3be9491c0d69f068cfeda9d8/kotlin-stdlib-common-1.3.50-dev-397.jar" output-file-name="kotlin-stdlib-common.jar" />
|
||||
<element id="file-copy" path="$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.3.50-dev-397/908a2bdb953a6cc1e0ee306066b435c7469bc1/kotlin-stdlib-common-1.3.50-dev-397-sources.jar" output-file-name="kotlin-stdlib-common-sources.jar" />
|
||||
</element>
|
||||
<element id="directory" name="js">
|
||||
<element id="extracted-dir" path="$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-js/1.3.50-dev-526/8a798b744fdbd46a7d93814f0f0b97c664c064d2/kotlin-stdlib-js-1.3.50-dev-526.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-js/1.3.50-dev-397/8fecb29089c335c4cb37f2ae37f204bd8c0a015/kotlin-stdlib-js-1.3.50-dev-397.jar" path-in-jar="/" />
|
||||
</element>
|
||||
<element id="directory" name="maven">
|
||||
<element id="file-copy" path="$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.3.50-dev-526/21e04af851994238d364653c103df336bf45fd4d/kotlin-stdlib-1.3.50-dev-526-sources.jar" output-file-name="kotlin-stdlib-sources.jar" />
|
||||
<element id="file-copy" path="$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.3.50-dev-397/49551e2d0590be904a7178f881a90753425fe8e0/kotlin-stdlib-1.3.50-dev-397-sources.jar" output-file-name="kotlin-stdlib-sources.jar" />
|
||||
</element>
|
||||
<element id="directory" name="kotlinc">
|
||||
<element id="artifact" artifact-name="kotlinc" />
|
||||
|
||||
2
.idea/artifacts/kotlin_compiler_jar.xml
generated
2
.idea/artifacts/kotlin_compiler_jar.xml
generated
@@ -8,7 +8,7 @@
|
||||
</element>
|
||||
<element id="file-copy" path="$PROJECT_DIR$/prepare/compiler/build/tmp/packCompiler/MANIFEST.MF" />
|
||||
</element>
|
||||
<element id="extracted-dir" path="$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/builtins/1.3.50-dev-526/7dbbf186f7b89e37e7a8f91cb86db2f50440dcc4/builtins-1.3.50-dev-526.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/builtins/1.3.50-dev-397/842ec330289185e9ea136dd86f2846b6ff9a8a10/builtins-1.3.50-dev-397.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$PROJECT_DIR$/dependencies/repo/kotlin.build/ideaIC/191.6707.61/artifacts/lib/asm-all-7.0.1.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$PROJECT_DIR$/dependencies/repo/kotlin.build/ideaIC/191.6707.61/artifacts/lib/guava-25.1-jre.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$PROJECT_DIR$/dependencies/repo/kotlin.build/intellij-core/191.6707.61/artifacts/intellij-core.jar" path-in-jar="/" />
|
||||
|
||||
16
.idea/artifacts/kotlinc.xml
generated
16
.idea/artifacts/kotlinc.xml
generated
@@ -226,14 +226,14 @@
|
||||
<element id="file-copy" path="$PROJECT_DIR$/plugins/android-extensions/android-extensions-compiler/build/tmp/jar/MANIFEST.MF" />
|
||||
</element>
|
||||
</element>
|
||||
<element id="file-copy" path="$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk8/1.3.50-dev-526/d9da4521258618dcc687690f81e7430544098a80/kotlin-stdlib-jdk8-1.3.50-dev-526.jar" output-file-name="kotlin-stdlib-jdk8.jar" />
|
||||
<element id="file-copy" path="$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk7/1.3.50-dev-526/8c795ad16d3e2edd465d97cda4063f906a4ecbaa/kotlin-stdlib-jdk7-1.3.50-dev-526.jar" output-file-name="kotlin-stdlib-jdk7.jar" />
|
||||
<element id="file-copy" path="$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.3.50-dev-526/2fbb7e5d5a32d0754ee33e8ca38696fa22a3b70b/kotlin-stdlib-1.3.50-dev-526.jar" output-file-name="kotlin-stdlib.jar" />
|
||||
<element id="file-copy" path="$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk7/1.3.50-dev-526/7c73dd25222b54224562d17184296dc8450c80cf/kotlin-stdlib-jdk7-1.3.50-dev-526-sources.jar" output-file-name="kotlin-stdlib-jdk7-sources.jar" />
|
||||
<element id="file-copy" path="$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk8/1.3.50-dev-526/e9f538ede7b49a4d60265aa90f907d39993417d9/kotlin-stdlib-jdk8-1.3.50-dev-526-sources.jar" output-file-name="kotlin-stdlib-jdk8-sources.jar" />
|
||||
<element id="file-copy" path="$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-js/1.3.50-dev-526/f171da8782d7f0000142818532b5e49693becb99/kotlin-stdlib-js-1.3.50-dev-526-sources.jar" />
|
||||
<element id="file-copy" path="$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-js/1.3.50-dev-526/8a798b744fdbd46a7d93814f0f0b97c664c064d2/kotlin-stdlib-js-1.3.50-dev-526.jar" output-file-name="kotlin-stdlib-js.jar" />
|
||||
<element id="file-copy" path="$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.3.50-dev-526/21e04af851994238d364653c103df336bf45fd4d/kotlin-stdlib-1.3.50-dev-526-sources.jar" output-file-name="kotlin-stdlib-sources.jar" />
|
||||
<element id="file-copy" path="$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk8/1.3.50-dev-397/cea97f07f62c8c851aca7dc9710d9c0214b585ad/kotlin-stdlib-jdk8-1.3.50-dev-397.jar" output-file-name="kotlin-stdlib-jdk8.jar" />
|
||||
<element id="file-copy" path="$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk7/1.3.50-dev-397/37b7a5e6a0178c1ef97d486c2baaab0b07e119d9/kotlin-stdlib-jdk7-1.3.50-dev-397.jar" output-file-name="kotlin-stdlib-jdk7.jar" />
|
||||
<element id="file-copy" path="$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.3.50-dev-397/a49478f35e92b4bf2e1a3bd628dc71e561d2eb04/kotlin-stdlib-1.3.50-dev-397.jar" output-file-name="kotlin-stdlib.jar" />
|
||||
<element id="file-copy" path="$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk7/1.3.50-dev-397/d87ad86ff1d0f960c89bee95c4f643297e54f9f1/kotlin-stdlib-jdk7-1.3.50-dev-397-sources.jar" output-file-name="kotlin-stdlib-jdk7-sources.jar" />
|
||||
<element id="file-copy" path="$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk8/1.3.50-dev-397/1f51a4f91853cfea7a295fd3154b11ed16d64932/kotlin-stdlib-jdk8-1.3.50-dev-397-sources.jar" output-file-name="kotlin-stdlib-jdk8-sources.jar" />
|
||||
<element id="file-copy" path="$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-js/1.3.50-dev-397/a6fb09cf5de9f1afa10699ae2b58156067307cd/kotlin-stdlib-js-1.3.50-dev-397-sources.jar" />
|
||||
<element id="file-copy" path="$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-js/1.3.50-dev-397/8fecb29089c335c4cb37f2ae37f204bd8c0a015/kotlin-stdlib-js-1.3.50-dev-397.jar" output-file-name="kotlin-stdlib-js.jar" />
|
||||
<element id="file-copy" path="$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.3.50-dev-397/49551e2d0590be904a7178f881a90753425fe8e0/kotlin-stdlib-1.3.50-dev-397-sources.jar" output-file-name="kotlin-stdlib-sources.jar" />
|
||||
<element id="artifact" artifact-name="kotlin-compiler.jar" />
|
||||
<element id="artifact" artifact-name="kotlin-reflect.jar" />
|
||||
<element id="artifact" artifact-name="kotlin-daemon-client.jar" />
|
||||
|
||||
@@ -27,7 +27,6 @@ import org.jetbrains.kotlin.metadata.js.JsProtoBuf
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.name.parentOrNull
|
||||
import org.jetbrains.kotlin.serialization.deserialization.getClassId
|
||||
import org.jetbrains.kotlin.serialization.js.JsSerializerProtocol
|
||||
import java.io.DataInput
|
||||
@@ -42,7 +41,6 @@ open class IncrementalJsCache(
|
||||
private const val TRANSLATION_RESULT_MAP = "translation-result"
|
||||
private const val INLINE_FUNCTIONS = "inline-functions"
|
||||
private const val HEADER_FILE_NAME = "header.meta"
|
||||
private const val PACKAGE_META_FILE = "packages-meta"
|
||||
|
||||
fun hasHeaderFile(cachesDir: File) = File(cachesDir, HEADER_FILE_NAME).exists()
|
||||
}
|
||||
@@ -51,7 +49,6 @@ open class IncrementalJsCache(
|
||||
override val dirtyOutputClassesMap = registerMap(DirtyClassesFqNameMap(DIRTY_OUTPUT_CLASSES.storageFile))
|
||||
private val translationResults = registerMap(TranslationResultMap(TRANSLATION_RESULT_MAP.storageFile, pathConverter))
|
||||
private val inlineFunctions = registerMap(InlineFunctionsMap(INLINE_FUNCTIONS.storageFile, pathConverter))
|
||||
private val packageMetadata = registerMap(PackageMetadataMap(PACKAGE_META_FILE.storageFile))
|
||||
|
||||
private val dirtySources = hashSetOf<File>()
|
||||
|
||||
@@ -66,12 +63,6 @@ open class IncrementalJsCache(
|
||||
}
|
||||
|
||||
override fun markDirty(removedAndCompiledSources: Collection<File>) {
|
||||
removedAndCompiledSources.forEach { sourceFile ->
|
||||
// The common prefix of all FQN parents has to be the file package
|
||||
sourceToClassesMap[sourceFile].map { it.parentOrNull()?.asString() ?: "" }.minBy { it.length }?.let {
|
||||
packageMetadata.remove(it)
|
||||
}
|
||||
}
|
||||
super.markDirty(removedAndCompiledSources)
|
||||
dirtySources.addAll(removedAndCompiledSources)
|
||||
}
|
||||
@@ -104,10 +95,6 @@ open class IncrementalJsCache(
|
||||
for ((srcFile, inlineDeclarations) in incrementalResults.inlineFunctions) {
|
||||
inlineFunctions.process(srcFile, inlineDeclarations, changesCollector)
|
||||
}
|
||||
|
||||
for ((packageName, metadata) in incrementalResults.packageMetadata) {
|
||||
packageMetadata.put(packageName, metadata)
|
||||
}
|
||||
}
|
||||
|
||||
private fun registerOutputForFile(srcFile: File, name: FqName) {
|
||||
@@ -128,18 +115,11 @@ open class IncrementalJsCache(
|
||||
fun nonDirtyPackageParts(): Map<File, TranslationResultValue> =
|
||||
hashMapOf<File, TranslationResultValue>().apply {
|
||||
for (file in translationResults.keys()) {
|
||||
|
||||
if (file !in dirtySources) {
|
||||
put(file, translationResults[file]!!)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun packageMetadata(): Map<String, ByteArray> = hashMapOf<String, ByteArray>().apply {
|
||||
for (fqNameString in packageMetadata.keys()) {
|
||||
put(fqNameString, packageMetadata[fqNameString]!!)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private object TranslationResultValueExternalizer : DataExternalizer<TranslationResultValue> {
|
||||
@@ -174,8 +154,7 @@ private object TranslationResultValueExternalizer : DataExternalizer<Translation
|
||||
private class TranslationResultMap(
|
||||
storageFile: File,
|
||||
private val pathConverter: FileToPathConverter
|
||||
) :
|
||||
BasicStringMap<TranslationResultValue>(storageFile, TranslationResultValueExternalizer) {
|
||||
) : BasicStringMap<TranslationResultValue>(storageFile, TranslationResultValueExternalizer) {
|
||||
override fun dumpValue(value: TranslationResultValue): String =
|
||||
"Metadata: ${value.metadata.md5()}, Binary AST: ${value.binaryAst.md5()}, InlineData: ${value.inlineData.md5()}"
|
||||
|
||||
@@ -202,7 +181,7 @@ private class TranslationResultMap(
|
||||
}
|
||||
}
|
||||
|
||||
fun getProtoData(sourceFile: File, metadata: ByteArray): Map<ClassId, ProtoData> {
|
||||
fun getProtoData(sourceFile: File, metadata: ByteArray): Map<ClassId, ProtoData> {
|
||||
val classes = hashMapOf<ClassId, ProtoData>()
|
||||
val proto = ProtoBuf.PackageFragment.parseFrom(metadata, JsSerializerProtocol.extensionRegistry)
|
||||
val nameResolver = NameResolverImpl(proto.strings, proto.qualifiedNames)
|
||||
@@ -248,35 +227,4 @@ private class InlineFunctionsMap(
|
||||
|
||||
override fun dumpValue(value: Map<String, Long>): String =
|
||||
value.dumpMap { java.lang.Long.toHexString(it) }
|
||||
}
|
||||
|
||||
private object ByteArrayExternalizer : DataExternalizer<ByteArray> {
|
||||
override fun save(output: DataOutput, value: ByteArray) {
|
||||
output.writeInt(value.size)
|
||||
output.write(value)
|
||||
}
|
||||
|
||||
override fun read(input: DataInput): ByteArray {
|
||||
val size = input.readInt()
|
||||
val array = ByteArray(size)
|
||||
input.readFully(array)
|
||||
return array
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private class PackageMetadataMap(storageFile: File) : BasicStringMap<ByteArray>(storageFile, ByteArrayExternalizer) {
|
||||
fun put(packageName: String, newMetadata: ByteArray) {
|
||||
storage[packageName] = newMetadata
|
||||
}
|
||||
|
||||
fun remove(packageName: String) {
|
||||
storage.remove(packageName)
|
||||
}
|
||||
|
||||
fun keys() = storage.keys
|
||||
|
||||
operator fun get(packageName: String) = storage[packageName]
|
||||
|
||||
override fun dumpValue(value: ByteArray): String = "Package metadata: ${value.md5()}"
|
||||
}
|
||||
@@ -18,7 +18,4 @@ class IncrementalDataProviderFromCache(private val cache: IncrementalJsCache) :
|
||||
|
||||
override val metadataVersion: IntArray
|
||||
get() = JsMetadataVersion.INSTANCE.toArray() // TODO: store and load correct metadata version
|
||||
|
||||
override val packageMetadata: Map<String, ByteArray>
|
||||
get() = cache.packageMetadata()
|
||||
}
|
||||
|
||||
@@ -205,7 +205,7 @@ private fun kjsmToString(kjsmFile: File): String {
|
||||
}
|
||||
|
||||
private fun sourceMapFileToString(sourceMapFile: File, generatedJsFile: File): String {
|
||||
val sourceMapParseResult = SourceMapParser.parse(sourceMapFile.readText())
|
||||
val sourceMapParseResult = SourceMapParser.parse(StringReader(sourceMapFile.readText()))
|
||||
return when (sourceMapParseResult) {
|
||||
is SourceMapSuccess -> {
|
||||
val bytesOut = ByteArrayOutputStream()
|
||||
|
||||
@@ -34443,7 +34443,7 @@ public final class DebugProtoBuf {
|
||||
"tbrains.kotlin.metadata.VersionRequireme" +
|
||||
"nt.Level:\005ERROR\022\022\n\nerror_code\030\004 \001(\005\022\025\n\007m" +
|
||||
"essage\030\005 \001(\005B\004\230\265\030\001\022e\n\014version_kind\030\006 \001(\016" +
|
||||
"2=.org.jetbrains.kotlin.metadata.Version" +
|
||||
"2=.org.jetbrains.kotlin.metadata.version" +
|
||||
"Requirement.VersionKind:\020LANGUAGE_VERSIO" +
|
||||
"N\"+\n\005Level\022\013\n\007WARNING\020\000\022\t\n\005ERROR\020\001\022\n\n\006HI" +
|
||||
"DDEN\020\002\"J\n\013VersionKind\022\024\n\020LANGUAGE_VERSIO" +
|
||||
|
||||
@@ -4613,7 +4613,7 @@ public final class DebugJvmProtoBuf {
|
||||
* <code>extend .org.jetbrains.kotlin.metadata.Class { ... }</code>
|
||||
*
|
||||
* <pre>
|
||||
* If absent, assumed to be "main" (JvmProtoBufUtil.DEFAULT_MODULE_NAME)
|
||||
* If absent, assumed to be JvmAbi.DEFAULT_MODULE_NAME
|
||||
* </pre>
|
||||
*/
|
||||
public static final
|
||||
|
||||
@@ -9,17 +9,12 @@ buildscript {
|
||||
extra["defaultSnapshotVersion"] = "1.3-SNAPSHOT"
|
||||
|
||||
// when updating please also update JPS artifacts configuration: https://jetbrains.quip.com/zzGUAYSJ6gv3/JPS-Build-update-bootstrap
|
||||
kotlinBootstrapFrom(BootstrapOption.TeamCity("1.3.50-dev-526", onlySuccessBootstrap = false))
|
||||
kotlinBootstrapFrom(BootstrapOption.TeamCity("1.3.50-dev-397", onlySuccessBootstrap = false))
|
||||
|
||||
repositories {
|
||||
repositories.withRedirector(project) {
|
||||
bootstrapKotlinRepo?.let(::maven)
|
||||
|
||||
val cacheRedirectorEnabled = findProperty("cacheRedirectorEnabled")?.toString()?.toBoolean() == true
|
||||
if (cacheRedirectorEnabled) {
|
||||
maven("https://cache-redirector.jetbrains.com/plugins.gradle.org/m2")
|
||||
} else {
|
||||
maven("https://plugins.gradle.org/m2")
|
||||
}
|
||||
maven("https://plugins.gradle.org/m2")
|
||||
maven("https://dl.bintray.com/kotlin/ktor")
|
||||
}
|
||||
|
||||
// a workaround for kotlin compiler classpath in kotlin project: sometimes gradle substitutes
|
||||
@@ -34,6 +29,15 @@ buildscript {
|
||||
classpath(kotlin("gradle-plugin", bootstrapKotlinVersion))
|
||||
classpath("net.sf.proguard:proguard-gradle:6.1.0")
|
||||
classpath("org.jetbrains.dokka:dokka-gradle-plugin:0.9.17")
|
||||
|
||||
// a workaround to add another one buildSrc with Cidr-specific tools to Gradle classpath
|
||||
val kotlinUltimateBuildSrcDep = "org.jetbrains.kotlin.ultimate:buildSrc:1.0"
|
||||
if (findProperty("cidrPluginsEnabled")?.toString()?.toBoolean() == true) {
|
||||
logger.info("Adding buildscript classpath dependency \"$kotlinUltimateBuildSrcDep\" in build.gradle.kts")
|
||||
classpath(kotlinUltimateBuildSrcDep)
|
||||
} else {
|
||||
logger.info("NOT adding buildscript classpath dependency \"$kotlinUltimateBuildSrcDep\" in build.gradle.kts")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -176,6 +180,7 @@ extra["versions.org.springframework"] = "4.2.0.RELEASE"
|
||||
extra["versions.jflex"] = "1.7.0"
|
||||
extra["versions.markdown"] = "0.1.25"
|
||||
extra["versions.trove4j"] = "1.0.20181211"
|
||||
extra["versions.kotlin-native-shared"] = "1.0-dev-73"
|
||||
|
||||
// NOTE: please, also change KTOR_NAME in pathUtil.kt and all versions in corresponding jar names in daemon tests.
|
||||
extra["versions.ktor-network"] = "1.0.1"
|
||||
@@ -225,8 +230,6 @@ extra["compilerModules"] = arrayOf(
|
||||
":compiler:backend.js",
|
||||
":compiler:ir.serialization.common",
|
||||
":compiler:ir.serialization.js",
|
||||
":kotlin-util-io",
|
||||
":kotlin-util-klib",
|
||||
":compiler:backend-common",
|
||||
":compiler:backend",
|
||||
":compiler:plugin-api",
|
||||
@@ -330,13 +333,13 @@ allprojects {
|
||||
repositories {
|
||||
kotlinBuildLocalRepo(project)
|
||||
mirrorRepo?.let(::maven)
|
||||
bootstrapKotlinRepo?.let(::maven)
|
||||
jcenter()
|
||||
maven(protobufRepo)
|
||||
maven(intellijRepo)
|
||||
maven(bootstrapKotlinRepo!!.replace("artifacts/content/maven/", "artifacts/content/internal/repo"))
|
||||
maven(kotlinNativeRepo)
|
||||
maven("https://dl.bintray.com/kotlin/ktor")
|
||||
maven("https://kotlin.bintray.com/kotlin-dependencies")
|
||||
bootstrapKotlinRepo?.let(::maven)
|
||||
internalKotlinRepo?.let(::maven)
|
||||
}
|
||||
|
||||
configureJvmProject(javaHome!!, jvmTarget!!)
|
||||
@@ -409,10 +412,10 @@ allprojects {
|
||||
}
|
||||
}
|
||||
|
||||
// Aggregate task for build related checks
|
||||
tasks.register("checkBuild")
|
||||
|
||||
apply(from = "$rootDir/gradle/cacheRedirector.gradle.kts")
|
||||
if (cacheRedirectorEnabled()) {
|
||||
logger.info("Redirecting repositories for $displayName")
|
||||
repositories.redirect()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -523,12 +526,7 @@ tasks {
|
||||
create("scriptingTest") {
|
||||
dependsOn("dist")
|
||||
dependsOn(":kotlin-script-util:test")
|
||||
dependsOn(":kotlin-scripting-compiler:test")
|
||||
dependsOn(":kotlin-scripting-jvm-host-test:test")
|
||||
dependsOn(":kotlin-scripting-jsr223-test:test")
|
||||
dependsOn(":kotlin-scripting-jvm-host-test:embeddableTest")
|
||||
dependsOn(":kotlin-scripting-jsr223-test:embeddableTest")
|
||||
dependsOn(":kotlin-main-kts-test:test")
|
||||
dependsOn(":kotlin-scripting-jvm-host:test")
|
||||
}
|
||||
|
||||
create("compilerTest") {
|
||||
@@ -587,10 +585,7 @@ tasks {
|
||||
":idea:idea-maven:test",
|
||||
":j2k:test",
|
||||
":nj2k:test",
|
||||
":idea:jvm-debugger:jvm-debugger-core:test",
|
||||
":idea:jvm-debugger:jvm-debugger-evaluation:test",
|
||||
":idea:jvm-debugger:jvm-debugger-sequence:test",
|
||||
":idea:jvm-debugger:eval4j:test"
|
||||
":idea:eval4j:test"
|
||||
)
|
||||
}
|
||||
|
||||
@@ -621,7 +616,6 @@ tasks {
|
||||
":kotlin-sam-with-receiver-compiler-plugin:test",
|
||||
":plugins:uast-kotlin:test",
|
||||
":kotlin-annotation-processing-gradle:test",
|
||||
":kotlinx-serialization-compiler-plugin:test",
|
||||
":kotlinx-serialization-ide-plugin:test"
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
extra["versions.shadow"] = "4.0.3"
|
||||
extra["versions.native-platform"] = "0.14"
|
||||
|
||||
buildscript {
|
||||
val cacheRedirectorEnabled = findProperty("cacheRedirectorEnabled")?.toString()?.toBoolean() == true
|
||||
|
||||
val buildSrcKotlinVersion: String by extra(findProperty("buildSrc.kotlin.version")?.toString() ?: embeddedKotlinVersion)
|
||||
val buildSrcKotlinRepo: String? by extra(findProperty("buildSrc.kotlin.repo") as String?)
|
||||
extra["versions.shadow"] = "4.0.3"
|
||||
extra["versions.native-platform"] = "0.14"
|
||||
|
||||
repositories {
|
||||
if (cacheRedirectorEnabled) {
|
||||
maven("https://cache-redirector.jetbrains.com/jcenter.bintray.com")
|
||||
} else {
|
||||
jcenter()
|
||||
}
|
||||
|
||||
buildSrcKotlinRepo?.let {
|
||||
@@ -79,13 +77,18 @@ extra["versions.androidDxSources"] = "5.0.0_r2"
|
||||
extra["customDepsOrg"] = "kotlin.build"
|
||||
|
||||
repositories {
|
||||
maven("https://jetbrains.bintray.com/intellij-third-party-dependencies/")
|
||||
maven("https://plugins.gradle.org/m2/")
|
||||
jcenter()
|
||||
if (cacheRedirectorEnabled) {
|
||||
maven("https://cache-redirector.jetbrains.com/jcenter.bintray.com")
|
||||
maven("https://cache-redirector.jetbrains.com/jetbrains.bintray.com/intellij-third-party-dependencies/")
|
||||
}
|
||||
|
||||
extra["buildSrcKotlinRepo"]?.let {
|
||||
maven(url = it)
|
||||
}
|
||||
|
||||
jcenter()
|
||||
maven("https://jetbrains.bintray.com/intellij-third-party-dependencies/")
|
||||
maven("https://plugins.gradle.org/m2/")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@@ -109,11 +112,3 @@ fun Project.`samWithReceiver`(configure: org.jetbrains.kotlin.samWithReceiver.gr
|
||||
extensions.configure("samWithReceiver", configure)
|
||||
|
||||
tasks["build"].dependsOn(":prepare-deps:build")
|
||||
|
||||
allprojects {
|
||||
tasks.register("checkBuild")
|
||||
|
||||
afterEvaluate {
|
||||
apply(from = "$rootDir/../gradle/cacheRedirector.gradle.kts")
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,12 @@
|
||||
@file:Suppress("PropertyName", "HasPlatformType", "UnstableApiUsage")
|
||||
@file:Suppress("PropertyName")
|
||||
|
||||
import com.sun.xml.internal.txw2.output.IndentingXMLStreamWriter
|
||||
import org.gradle.api.publish.ivy.internal.artifact.FileBasedIvyArtifact
|
||||
import org.gradle.api.publish.ivy.internal.publication.DefaultIvyConfiguration
|
||||
import org.gradle.api.publish.ivy.internal.publication.DefaultIvyPublicationIdentity
|
||||
import org.gradle.api.publish.ivy.internal.publisher.IvyDescriptorFileGenerator
|
||||
import org.gradle.internal.os.OperatingSystem
|
||||
import java.io.FileWriter
|
||||
import java.net.URI
|
||||
import javax.xml.stream.XMLOutputFactory
|
||||
import javax.xml.stream.XMLStreamWriter
|
||||
|
||||
plugins {
|
||||
base
|
||||
}
|
||||
|
||||
val cacheRedirectorEnabled = findProperty("cacheRedirectorEnabled")?.toString()?.toBoolean() == true
|
||||
val verifyDependencyOutput: Boolean by rootProject.extra
|
||||
val intellijUltimateEnabled: Boolean by rootProject.extra
|
||||
val intellijReleaseType: String by rootProject.extra
|
||||
@@ -22,6 +18,9 @@ val intellijSeparateSdks: Boolean by rootProject.extra
|
||||
val installIntellijCommunity = !intellijUltimateEnabled || intellijSeparateSdks
|
||||
val installIntellijUltimate = intellijUltimateEnabled
|
||||
|
||||
val androidBuildToolsVersion = rootProject.extra["versions.androidBuildTools"] as String
|
||||
val androidDxSourcesVersion = rootProject.extra["versions.androidDxSources"] as String
|
||||
|
||||
val intellijVersionDelimiterIndex = intellijVersion.indexOfAny(charArrayOf('.', '-'))
|
||||
if (intellijVersionDelimiterIndex == -1) {
|
||||
error("Invalid IDEA version $intellijVersion")
|
||||
@@ -50,21 +49,47 @@ val androidStudioOs by lazy {
|
||||
}
|
||||
}
|
||||
|
||||
val androidToolsOs by lazy {
|
||||
when {
|
||||
OperatingSystem.current().isWindows -> "windows"
|
||||
OperatingSystem.current().isMacOsX -> "macosx"
|
||||
OperatingSystem.current().isLinux -> "linux"
|
||||
else -> {
|
||||
logger.error("Unknown operating system for android tools: ${OperatingSystem.current().name}")
|
||||
""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
repositories {
|
||||
if (androidStudioRelease != null) {
|
||||
ivy {
|
||||
url = URI("https://dl.google.com/dl/android/studio/ide-zips/$androidStudioRelease")
|
||||
|
||||
patternLayout {
|
||||
artifact("[artifact]-[revision]-$androidStudioOs.[ext]")
|
||||
if (cacheRedirectorEnabled) {
|
||||
artifactPattern("https://cache-redirector.jetbrains.com/dl.google.com/dl/android/studio/ide-zips/$androidStudioRelease/[artifact]-[revision]-$androidStudioOs.[ext]")
|
||||
}
|
||||
|
||||
artifactPattern("https://dl.google.com/dl/android/studio/ide-zips/$androidStudioRelease/[artifact]-[revision]-$androidStudioOs.[ext]")
|
||||
metadataSources {
|
||||
artifact()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ivy {
|
||||
artifactPattern("https://dl.google.com/android/repository/[artifact]_[revision](-[classifier]).[ext]")
|
||||
artifactPattern("https://android.googlesource.com/platform/dalvik/+archive/android-$androidDxSourcesVersion/[artifact].[ext]")
|
||||
metadataSources {
|
||||
artifact()
|
||||
}
|
||||
}
|
||||
|
||||
if (cacheRedirectorEnabled) {
|
||||
maven("https://cache-redirector.jetbrains.com/www.jetbrains.com/intellij-repository/$intellijReleaseType")
|
||||
maven("https://cache-redirector.jetbrains.com/plugins.jetbrains.com/maven")
|
||||
maven("https://cache-redirector.jetbrains.com/jetbrains.bintray.com/intellij-third-party-dependencies/")
|
||||
}
|
||||
|
||||
maven("https://www.jetbrains.com/intellij-repository/$intellijReleaseType")
|
||||
maven("https://plugins.jetbrains.com/maven")
|
||||
maven("https://jetbrains.bintray.com/intellij-third-party-dependencies/")
|
||||
@@ -77,6 +102,8 @@ val sources by configurations.creating
|
||||
val jpsStandalone by configurations.creating
|
||||
val intellijCore by configurations.creating
|
||||
val nodeJSPlugin by configurations.creating
|
||||
val androidBuildTools by configurations.creating
|
||||
val androidDxSources by configurations.creating
|
||||
|
||||
/**
|
||||
* Special repository for annotations.jar required for idea runtime only.
|
||||
@@ -90,6 +117,10 @@ val customDepsOrg: String by rootProject.extra
|
||||
val customDepsRevision = intellijVersion
|
||||
val repoDir = File(customDepsRepoDir, customDepsOrg)
|
||||
|
||||
val androidDxModuleName = "android-dx"
|
||||
val androidDxRevision = androidBuildToolsVersion
|
||||
val androidDxRepoModuleDir = File(repoDir, "$androidDxModuleName/$androidDxRevision")
|
||||
|
||||
dependencies {
|
||||
if (androidStudioRelease != null) {
|
||||
val extension = if (androidStudioOs == "linux" && androidStudioRelease.startsWith("3.5"))
|
||||
@@ -117,6 +148,66 @@ dependencies {
|
||||
if (intellijUltimateEnabled) {
|
||||
nodeJSPlugin("com.jetbrains.plugins:NodeJS:${rootProject.extra["versions.idea.NodeJS"]}@zip")
|
||||
}
|
||||
|
||||
androidBuildTools("google:build-tools:$androidBuildToolsVersion:$androidToolsOs@zip")
|
||||
androidDxSources("google:dx:0@tar.gz")
|
||||
}
|
||||
|
||||
val dxSourcesTargetDir = File(buildDir, "dx_src")
|
||||
|
||||
val untarDxSources by tasks.creating {
|
||||
dependsOn(androidDxSources)
|
||||
inputs.files(androidDxSources)
|
||||
outputs.dir(dxSourcesTargetDir)
|
||||
doFirst {
|
||||
project.copy {
|
||||
from(tarTree(androidDxSources.singleFile))
|
||||
include("src/**")
|
||||
includeEmptyDirs = false
|
||||
into(dxSourcesTargetDir)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val prepareDxSourcesJar by tasks.creating(Jar::class) {
|
||||
dependsOn(untarDxSources)
|
||||
from("$dxSourcesTargetDir/src")
|
||||
destinationDir = File(repoDir, sources.name)
|
||||
baseName = androidDxModuleName
|
||||
classifier = "sources"
|
||||
version = androidBuildToolsVersion
|
||||
}
|
||||
|
||||
val unzipDxJar by tasks.creating {
|
||||
dependsOn(androidBuildTools)
|
||||
inputs.files(androidBuildTools)
|
||||
outputs.files(File(androidDxRepoModuleDir, "dx.jar"))
|
||||
doFirst {
|
||||
project.copy {
|
||||
from(zipTree(androidBuildTools.singleFile).files)
|
||||
include("**/dx.jar")
|
||||
into(androidDxRepoModuleDir)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val buildIvyRepoForAndroidDx by tasks.creating {
|
||||
dependsOn(unzipDxJar, prepareDxSourcesJar)
|
||||
inputs.files(unzipDxJar, prepareDxSourcesJar)
|
||||
outputs.file(File(androidDxRepoModuleDir, "$androidDxModuleName.ivy.xml"))
|
||||
|
||||
doLast {
|
||||
writeIvyXml(
|
||||
customDepsOrg,
|
||||
androidDxModuleName,
|
||||
androidBuildToolsVersion,
|
||||
androidDxModuleName,
|
||||
androidDxRepoModuleDir,
|
||||
androidDxRepoModuleDir,
|
||||
androidDxRepoModuleDir,
|
||||
prepareDxSourcesJar.outputs.files.singleFile
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
val makeIntellijCore = buildIvyRepositoryTask(intellijCore, customDepsOrg, customDepsRepoDir)
|
||||
@@ -149,10 +240,10 @@ val makeIntellijAnnotations by tasks.creating(Copy::class.java) {
|
||||
val mergeSources by tasks.creating(Jar::class.java) {
|
||||
dependsOn(sources)
|
||||
from(provider { sources.map(::zipTree) })
|
||||
destinationDirectory.set(File(repoDir, sources.name))
|
||||
archiveBaseName.set("intellij")
|
||||
archiveClassifier.set("sources")
|
||||
archiveVersion.set(intellijVersion)
|
||||
destinationDir = File(repoDir, sources.name)
|
||||
baseName = "intellij"
|
||||
classifier = "sources"
|
||||
version = intellijVersion
|
||||
}
|
||||
|
||||
val sourcesFile = mergeSources.outputs.files.singleFile
|
||||
@@ -181,19 +272,19 @@ val makeIde = if (androidStudioBuild != null) {
|
||||
task
|
||||
}
|
||||
|
||||
val buildJpsStandalone = buildIvyRepositoryTask(jpsStandalone, customDepsOrg, customDepsRepoDir, null, sourcesFile)
|
||||
val buildNodeJsPlugin = buildIvyRepositoryTask(nodeJSPlugin, customDepsOrg, customDepsRepoDir, ::skipToplevelDirectory, sourcesFile)
|
||||
|
||||
tasks.named("build") {
|
||||
val build by tasks.creating {
|
||||
dependsOn(
|
||||
makeIntellijCore,
|
||||
makeIde,
|
||||
buildJpsStandalone,
|
||||
makeIntellijAnnotations
|
||||
buildIvyRepositoryTask(jpsStandalone, customDepsOrg, customDepsRepoDir, null, sourcesFile),
|
||||
makeIntellijAnnotations,
|
||||
buildIvyRepoForAndroidDx
|
||||
)
|
||||
|
||||
if (installIntellijUltimate) {
|
||||
dependsOn(buildNodeJsPlugin)
|
||||
dependsOn(
|
||||
buildIvyRepositoryTask(nodeJSPlugin, customDepsOrg, customDepsRepoDir, ::skipToplevelDirectory, sourcesFile)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -203,7 +294,7 @@ tasks.create("cleanLegacy", Delete::class.java) {
|
||||
delete("$projectDir/intellij-sdk")
|
||||
}
|
||||
|
||||
tasks.named<Delete>("clean") {
|
||||
tasks.create("clean", Delete::class.java) {
|
||||
delete(customDepsRepoDir)
|
||||
}
|
||||
|
||||
@@ -310,94 +401,40 @@ fun writeIvyXml(
|
||||
&& !jar.name.startsWith("kotlin-")
|
||||
&& (allowAnnotations || jar.name != "annotations.jar") // see comments for [intellijAnnotations] above
|
||||
|
||||
val ivyFile = targetDir.resolve("$fileName.ivy.xml")
|
||||
ivyFile.parentFile.mkdirs()
|
||||
FileWriter(ivyFile).use {
|
||||
val xmlWriter = IndentingXMLStreamWriter(XMLOutputFactory.newInstance().createXMLStreamWriter(it))
|
||||
with(xmlWriter) {
|
||||
document("UTF-8", "1.0") {
|
||||
element("ivy-module") {
|
||||
attribute("version", "2.0")
|
||||
attribute("xmlns:m", "http://ant.apache.org/ivy/maven")
|
||||
|
||||
emptyElement("info") {
|
||||
attributes(
|
||||
"organisation" to organization,
|
||||
"module" to moduleName,
|
||||
"revision" to version,
|
||||
"publication" to ""
|
||||
)
|
||||
with(IvyDescriptorFileGenerator(DefaultIvyPublicationIdentity(organization, moduleName, version))) {
|
||||
addConfiguration(DefaultIvyConfiguration("default"))
|
||||
addConfiguration(DefaultIvyConfiguration("sources"))
|
||||
artifactDir.listFiles()?.forEach { jarFile ->
|
||||
if (shouldIncludeIntellijJar(jarFile)) {
|
||||
val relativeName = jarFile.toRelativeString(baseDir).removeSuffix(".jar")
|
||||
addArtifact(
|
||||
FileBasedIvyArtifact(
|
||||
jarFile,
|
||||
DefaultIvyPublicationIdentity(organization, relativeName, version)
|
||||
).also {
|
||||
it.conf = "default"
|
||||
}
|
||||
|
||||
element("configurations") {
|
||||
listOf("default", "sources").forEach { configurationName ->
|
||||
emptyElement("conf") {
|
||||
attributes("name" to configurationName, "visibility" to "public")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
element("publications") {
|
||||
artifactDir.listFiles()?.filter(::shouldIncludeIntellijJar)?.forEach { jarFile ->
|
||||
val relativeName = jarFile.toRelativeString(baseDir).removeSuffix(".jar")
|
||||
emptyElement("artifact") {
|
||||
attributes(
|
||||
"name" to relativeName,
|
||||
"type" to "jar",
|
||||
"ext" to "jar",
|
||||
"conf" to "default"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
sourcesJar.forEach { jarFile ->
|
||||
emptyElement("artifact") {
|
||||
val sourcesArtifactName = jarFile.name
|
||||
.substringBeforeLast("-")
|
||||
.substringBeforeLast("-")
|
||||
|
||||
attributes(
|
||||
"name" to sourcesArtifactName,
|
||||
"type" to "jar",
|
||||
"ext" to "jar",
|
||||
"conf" to "sources",
|
||||
"m:classifier" to "sources"
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
flush()
|
||||
close()
|
||||
}
|
||||
|
||||
sourcesJar.forEach {
|
||||
val sourcesArtifactName = it.name.substringBeforeLast("-").substringBeforeLast("-")
|
||||
addArtifact(
|
||||
FileBasedIvyArtifact(
|
||||
it,
|
||||
DefaultIvyPublicationIdentity(organization, sourcesArtifactName, version)
|
||||
).also { artifact ->
|
||||
artifact.conf = "sources"
|
||||
artifact.classifier = "sources"
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
writeTo(File(targetDir, "$fileName.ivy.xml"))
|
||||
}
|
||||
}
|
||||
|
||||
fun skipToplevelDirectory(path: String) = path.substringAfter('/')
|
||||
|
||||
fun skipContentsDirectory(path: String) = path.substringAfter("Contents/")
|
||||
|
||||
fun XMLStreamWriter.document(encoding: String, version: String, init: XMLStreamWriter.() -> Unit) = apply {
|
||||
writeStartDocument(encoding, version)
|
||||
init()
|
||||
writeEndDocument()
|
||||
}
|
||||
|
||||
fun XMLStreamWriter.element(name: String, init: XMLStreamWriter.() -> Unit) = apply {
|
||||
writeStartElement(name)
|
||||
init()
|
||||
writeEndElement()
|
||||
}
|
||||
|
||||
fun XMLStreamWriter.emptyElement(name: String, init: XMLStreamWriter.() -> Unit) = apply {
|
||||
writeEmptyElement(name)
|
||||
init()
|
||||
}
|
||||
|
||||
fun XMLStreamWriter.attribute(name: String, value: String): Unit = writeAttribute(name, value)
|
||||
|
||||
fun XMLStreamWriter.attributes(vararg attributes: Pair<String, String>) {
|
||||
attributes.forEach { attribute(it.first, it.second) }
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
|
||||
pluginManagement {
|
||||
repositories {
|
||||
if (cacheRedirectorEnabled == 'true') {
|
||||
@@ -11,53 +12,3 @@ pluginManagement {
|
||||
}
|
||||
|
||||
include "prepare-deps"
|
||||
|
||||
def flags = new LocalBuildProperties(settings as Settings)
|
||||
|
||||
if (flags.includeCidrPlugins) {
|
||||
logger.info("Including CIDR plugins in buildSrc/settings.gradle")
|
||||
include ":prepare-deps:kotlin-native-platform-deps"
|
||||
project(":prepare-deps:kotlin-native-platform-deps").projectDir = file("${flags.propertiesProvider.rootProjectDir}/kotlin-ultimate/buildSrc/prepare-deps/kotlin-native-platform-deps")
|
||||
} else {
|
||||
logger.info("NOT including CIDR plugins in buildSrc/settings.gradle")
|
||||
}
|
||||
|
||||
class LocalBuildPropertiesProvider {
|
||||
private Settings settings
|
||||
private Properties localProperties = new Properties()
|
||||
|
||||
File rootProjectDir
|
||||
|
||||
LocalBuildPropertiesProvider(Settings settings) {
|
||||
this.settings = settings
|
||||
this.rootProjectDir = settings.rootProject.projectDir.parentFile
|
||||
|
||||
File propertiesFile = new File(rootProjectDir, 'local.properties')
|
||||
if (propertiesFile.isFile()) {
|
||||
propertiesFile.withInputStream { localProperties.load(it) }
|
||||
}
|
||||
}
|
||||
|
||||
String getString(String name) {
|
||||
if (settings.hasProperty(name)) {
|
||||
return settings[name]?.toString()
|
||||
} else {
|
||||
return localProperties[name]?.toString()
|
||||
}
|
||||
}
|
||||
|
||||
Boolean getBoolean(String name) {
|
||||
return Boolean.parseBoolean(getString(name))
|
||||
}
|
||||
}
|
||||
|
||||
class LocalBuildProperties {
|
||||
LocalBuildPropertiesProvider propertiesProvider
|
||||
|
||||
boolean includeCidrPlugins
|
||||
|
||||
LocalBuildProperties(Settings settings) {
|
||||
propertiesProvider = new LocalBuildPropertiesProvider(settings)
|
||||
includeCidrPlugins = propertiesProvider.getBoolean('cidrPluginsEnabled') && new File(propertiesProvider.rootProjectDir, 'kotlin-ultimate').exists()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,14 +7,10 @@ import org.gradle.kotlin.dsl.*
|
||||
var Project.bootstrapKotlinVersion: String
|
||||
get() = this.property("bootstrapKotlinVersion") as String
|
||||
private set(value) { this.extra["bootstrapKotlinVersion"] = value }
|
||||
|
||||
var Project.bootstrapKotlinRepo: String?
|
||||
get() = this.property("bootstrapKotlinRepo") as String?
|
||||
private set(value) { this.extra["bootstrapKotlinRepo"] = value }
|
||||
|
||||
val Project.internalKotlinRepo: String?
|
||||
get() = bootstrapKotlinRepo?.replace("artifacts/content/maven/", "artifacts/content/internal/repo")
|
||||
|
||||
fun Project.kotlinBootstrapFrom(defaultSource: BootstrapOption) {
|
||||
val customVersion = project.findProperty("bootstrap.kotlin.version") as String?
|
||||
val customRepo = project.findProperty("bootstrap.kotlin.repo") as String?
|
||||
|
||||
@@ -26,7 +26,7 @@ fun CompatibilityPredicate.or(other: CompatibilityPredicate): CompatibilityPredi
|
||||
}
|
||||
|
||||
enum class Platform : CompatibilityPredicate {
|
||||
P181, P182, P183, P191, P192;
|
||||
P181, P182, P183, P191;
|
||||
|
||||
val version: Int = name.drop(1).toInt()
|
||||
|
||||
@@ -45,7 +45,6 @@ enum class Ide(val platform: Platform) : CompatibilityPredicate {
|
||||
IJ182(Platform.P182),
|
||||
IJ183(Platform.P183),
|
||||
IJ191(Platform.P191),
|
||||
IJ192(Platform.P192),
|
||||
|
||||
AS32(Platform.P181),
|
||||
AS33(Platform.P182),
|
||||
|
||||
@@ -3,17 +3,15 @@
|
||||
import org.gradle.api.GradleException
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.Task
|
||||
import org.gradle.api.UnknownDomainObjectException
|
||||
import org.gradle.api.artifacts.ConfigurablePublishArtifact
|
||||
import org.gradle.api.artifacts.Configuration
|
||||
import org.gradle.api.artifacts.ConfigurationContainer
|
||||
import org.gradle.api.artifacts.component.ProjectComponentIdentifier
|
||||
import org.gradle.api.file.DuplicatesStrategy
|
||||
import org.gradle.api.file.SourceDirectorySet
|
||||
import org.gradle.api.internal.artifacts.publish.ArchivePublishArtifact
|
||||
import org.gradle.api.plugins.BasePluginConvention
|
||||
import org.gradle.api.plugins.JavaPluginConvention
|
||||
import org.gradle.api.tasks.AbstractCopyTask
|
||||
import org.gradle.api.tasks.Copy
|
||||
import org.gradle.api.tasks.TaskProvider
|
||||
import org.gradle.api.tasks.Upload
|
||||
import org.gradle.api.tasks.javadoc.Javadoc
|
||||
import org.gradle.jvm.tasks.Jar
|
||||
@@ -90,32 +88,23 @@ fun <T : Jar> Project.runtimeJar(task: T, body: T.() -> Unit = {}): T {
|
||||
|
||||
fun Project.runtimeJar(body: Jar.() -> Unit = {}): Jar = runtimeJar(getOrCreateTask("jar", body), { })
|
||||
|
||||
fun Project.sourcesJar(body: Jar.() -> Unit = {}): TaskProvider<Jar> {
|
||||
val task = tasks.register<Jar>("sourcesJar") {
|
||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||
archiveClassifier.set("sources")
|
||||
|
||||
from(project.mainSourceSet.allSource)
|
||||
|
||||
project.configurations.findByName("embedded")?.let { embedded ->
|
||||
from(provider {
|
||||
embedded.resolvedConfiguration
|
||||
.resolvedArtifacts
|
||||
.map { it.id.componentIdentifier }
|
||||
.filterIsInstance<ProjectComponentIdentifier>()
|
||||
.map { project(it.projectPath).mainSourceSet.allSource }
|
||||
})
|
||||
fun Project.sourcesJar(sourceSet: String? = "main", body: Jar.() -> Unit = {}): Jar =
|
||||
getOrCreateTask("sourcesJar") {
|
||||
setDuplicatesStrategy(DuplicatesStrategy.EXCLUDE)
|
||||
classifier = "sources"
|
||||
try {
|
||||
if (sourceSet != null) {
|
||||
project.pluginManager.withPlugin("java-base") {
|
||||
from(project.javaPluginConvention().sourceSets[sourceSet].allSource)
|
||||
}
|
||||
}
|
||||
} catch (e: UnknownDomainObjectException) {
|
||||
// skip default sources location
|
||||
}
|
||||
|
||||
body()
|
||||
project.addArtifact("archives", this, this)
|
||||
}
|
||||
|
||||
addArtifact("archives", task)
|
||||
addArtifact("sources", task)
|
||||
|
||||
return task
|
||||
}
|
||||
|
||||
fun Project.javadocJar(body: Jar.() -> Unit = {}): Jar = getOrCreateTask("javadocJar") {
|
||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||
classifier = "javadoc"
|
||||
@@ -205,11 +194,6 @@ fun Project.addArtifact(configuration: Configuration, task: Task, artifactRef: A
|
||||
fun Project.addArtifact(configurationName: String, task: Task, artifactRef: Any, body: ConfigurablePublishArtifact.() -> Unit = {}) =
|
||||
addArtifact(configurations.getOrCreate(configurationName), task, artifactRef, body)
|
||||
|
||||
fun <T : Task> Project.addArtifact(configurationName: String, task: TaskProvider<T>, body: ConfigurablePublishArtifact.() -> Unit = {}) {
|
||||
configurations.maybeCreate(configurationName)
|
||||
artifacts.add(configurationName, task, body)
|
||||
}
|
||||
|
||||
fun Project.cleanArtifacts() {
|
||||
configurations["archives"].artifacts.let { artifacts ->
|
||||
artifacts.forEach {
|
||||
|
||||
@@ -28,7 +28,7 @@ class KotlinBuildProperties(
|
||||
|
||||
private operator fun get(key: String): Any? = localProperties.getProperty(key) ?: propertiesProvider.getProperty(key)
|
||||
|
||||
private fun getBoolean(key: String): Boolean = this[key]?.toString()?.toBoolean() == true
|
||||
private fun getBoolean(key: String): Boolean = this[key]?.toString() == "true"
|
||||
|
||||
val isJpsBuildEnabled: Boolean = getBoolean("jpsBuild")
|
||||
|
||||
@@ -55,9 +55,6 @@ class KotlinBuildProperties(
|
||||
|
||||
val useBootstrapStdlib: Boolean
|
||||
get() = isInJpsBuildIdeaSync
|
||||
|
||||
val includeCidrPlugins: Boolean =
|
||||
getBoolean("cidrPluginsEnabled") && propertiesProvider.rootProjectDir.resolve("kotlin-ultimate").exists()
|
||||
}
|
||||
|
||||
private const val extensionName = "kotlinBuildFlags"
|
||||
|
||||
@@ -99,7 +99,11 @@ val Project.protobufRepo: String
|
||||
fun Project.protobufLite(): String = "org.jetbrains.kotlin:protobuf-lite:$protobufVersion"
|
||||
fun Project.protobufFull(): String = "org.jetbrains.kotlin:protobuf-relocated:$protobufVersion"
|
||||
|
||||
val Project.kotlinNativeRepo: String
|
||||
get() = "https://jetbrains.bintray.com/kotlin-native-dependencies"
|
||||
|
||||
val Project.kotlinNativeVersion: String get() = property("versions.kotlin-native") as String
|
||||
val Project.kotlinNativeSharedVersion: String get() = property("versions.kotlin-native-shared") as String
|
||||
|
||||
fun File.matchMaybeVersionedArtifact(baseName: String) = name.matches(baseName.toMaybeVersionedJarRegex())
|
||||
|
||||
|
||||
63
buildSrc/src/main/kotlin/jbCacheRedirector.kt
Normal file
63
buildSrc/src/main/kotlin/jbCacheRedirector.kt
Normal file
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.artifacts.dsl.RepositoryHandler
|
||||
import org.gradle.api.artifacts.repositories.MavenArtifactRepository
|
||||
import java.net.URI
|
||||
|
||||
// https://youtrack.jetbrains.com/issue/ADM-23180
|
||||
val mirroredUrls = listOf(
|
||||
"https://dl.bintray.com/groovy/maven",
|
||||
"https://dl.bintray.com/kotlin/kotlin-dev",
|
||||
"https://dl.bintray.com/kotlin/kotlin-eap",
|
||||
"https://dl.google.com/dl/android/maven2",
|
||||
"https://dl.google.com/go",
|
||||
"https://download.jetbrains.com",
|
||||
"https://jcenter.bintray.com",
|
||||
"https://jetbrains.bintray.com/dekaf",
|
||||
"https://jetbrains.bintray.com/intellij-jdk",
|
||||
"https://jetbrains.bintray.com/intellij-plugin-service",
|
||||
"https://jetbrains.bintray.com/intellij-third-party-dependencies",
|
||||
"https://jetbrains.bintray.com/markdown",
|
||||
"https://jetbrains.bintray.com/teamcity-rest-client",
|
||||
"https://jetbrains.bintray.com/test-discovery",
|
||||
"https://jetbrains.bintray.com/jediterm",
|
||||
"https://jitpack.io",
|
||||
"https://maven.exasol.com/artifactory/exasol-releases",
|
||||
"https://plugins.gradle.org/m2",
|
||||
"https://plugins.jetbrains.com/maven",
|
||||
"https://repo.grails.org/grails/core",
|
||||
"https://repo.jenkins-ci.org/releases",
|
||||
"https://repo.spring.io/milestone",
|
||||
"https://repo1.maven.org/maven2",
|
||||
"https://services.gradle.org",
|
||||
"https://www.jetbrains.com/intellij-repository",
|
||||
"https://www.myget.org/F/intellij-go-snapshots/maven",
|
||||
"https://www.myget.org/F/rd-snapshots/maven",
|
||||
"https://www.myget.org/F/rd-model-snapshots/maven",
|
||||
"https://www.python.org/ftp",
|
||||
"https://dl.google.com/dl/android/studio/ide-zips",
|
||||
"https://dl.bintray.com/kotlin/ktor",
|
||||
"https://cdn.azul.com/zulu/bin"
|
||||
)
|
||||
|
||||
fun URI.toCacheRedirectorUri() = URI("https://cache-redirector.jetbrains.com/$host/$path")
|
||||
|
||||
fun RepositoryHandler.redirect() = filterIsInstance<MavenArtifactRepository>().forEach { repository ->
|
||||
val uri = repository.url
|
||||
if (uri.toString().trimEnd('/') in mirroredUrls) {
|
||||
repository.url = uri.toCacheRedirectorUri()
|
||||
}
|
||||
}
|
||||
|
||||
fun Project.cacheRedirectorEnabled(): Boolean = findProperty("cacheRedirectorEnabled")?.toString()?.toBoolean() == true
|
||||
|
||||
fun RepositoryHandler.withRedirector(project: Project, configuration: RepositoryHandler.() -> Unit) {
|
||||
configuration()
|
||||
if (project.cacheRedirectorEnabled()) {
|
||||
redirect()
|
||||
}
|
||||
}
|
||||
@@ -42,19 +42,17 @@ private fun Project.ideModuleVersion() = when (IdeVersionConfigurator.currentIde
|
||||
|
||||
fun RepositoryHandler.kotlinBuildLocalRepo(project: Project): IvyArtifactRepository = ivy {
|
||||
val baseDir = project.kotlinBuildLocalRepoDir()
|
||||
url = baseDir.toURI()
|
||||
setUrl(baseDir)
|
||||
|
||||
patternLayout {
|
||||
ivy("[organisation]/[module]/[revision]/[module].ivy.xml")
|
||||
ivy("[organisation]/[module]/[revision]/ivy/[module].ivy.xml")
|
||||
ivy("[organisation]/${project.ideModuleName()}/[revision]/ivy/[module].ivy.xml") // bundled plugins
|
||||
ivyPattern("${baseDir.canonicalPath}/[organisation]/[module]/[revision]/[module].ivy.xml")
|
||||
ivyPattern("${baseDir.canonicalPath}/[organisation]/[module]/[revision]/ivy/[module].ivy.xml")
|
||||
ivyPattern("${baseDir.canonicalPath}/[organisation]/${project.ideModuleName()}/[revision]/ivy/[module].ivy.xml") // bundled plugins
|
||||
|
||||
artifact("[organisation]/[module]/[revision]/artifacts/lib/[artifact](-[classifier]).[ext]")
|
||||
artifact("[organisation]/[module]/[revision]/artifacts/[artifact](-[classifier]).[ext]")
|
||||
artifact("[organisation]/${project.ideModuleName()}/[revision]/artifacts/plugins/[module]/lib/[artifact](-[classifier]).[ext]") // bundled plugins
|
||||
artifact("[organisation]/sources/[artifact]-[revision](-[classifier]).[ext]")
|
||||
artifact("[organisation]/[module]/[revision]/[artifact](-[classifier]).[ext]")
|
||||
}
|
||||
artifactPattern("${baseDir.canonicalPath}/[organisation]/[module]/[revision]/artifacts/lib/[artifact](-[classifier]).[ext]")
|
||||
artifactPattern("${baseDir.canonicalPath}/[organisation]/[module]/[revision]/artifacts/[artifact](-[classifier]).[ext]")
|
||||
artifactPattern("${baseDir.canonicalPath}/[organisation]/${project.ideModuleName()}/[revision]/artifacts/plugins/[module]/lib/[artifact](-[classifier]).[ext]") // bundled plugins
|
||||
artifactPattern("${baseDir.canonicalPath}/[organisation]/sources/[artifact]-[revision](-[classifier]).[ext]")
|
||||
artifactPattern("${baseDir.canonicalPath}/[organisation]/[module]/[revision]/[artifact](-[classifier]).[ext]")
|
||||
|
||||
metadataSources {
|
||||
ivyDescriptor()
|
||||
@@ -69,7 +67,7 @@ fun Project.jpsStandalone() = "kotlin.build:jps-standalone:${rootProject.extra["
|
||||
|
||||
fun Project.nodeJSPlugin() = "kotlin.build:NodeJS:${rootProject.extra["versions.idea.NodeJS"]}"
|
||||
|
||||
fun Project.androidDxJar() = "org.jetbrains.kotlin:android-dx:${rootProject.extra["versions.androidBuildTools"]}"
|
||||
fun Project.androidDxJar() = "kotlin.build:android-dx:${rootProject.extra["versions.androidBuildTools"]}"
|
||||
|
||||
fun Project.jpsBuildTest() = "com.jetbrains.intellij.idea:jps-build-test:${rootProject.extra["versions.intellijSdk"]}"
|
||||
|
||||
|
||||
@@ -127,9 +127,7 @@ fun Project.projectTest(taskName: String = "test", parallel: Boolean = false, bo
|
||||
}
|
||||
|
||||
if (parallel) {
|
||||
maxParallelForks =
|
||||
project.findProperty("kotlin.test.maxParallelForks")?.toString()?.toInt()
|
||||
?: Math.max(Runtime.getRuntime().availableProcessors() / 2, 1)
|
||||
maxParallelForks = Math.max(Runtime.getRuntime().availableProcessors() / 2, 1)
|
||||
}
|
||||
body()
|
||||
}
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.backend.common
|
||||
|
||||
fun <T> Collection<T>.atMostOne(): T? {
|
||||
return when (this.size) {
|
||||
0 -> null
|
||||
1 -> this.iterator().next()
|
||||
else -> throw IllegalArgumentException("Collection has more than one element.")
|
||||
}
|
||||
}
|
||||
|
||||
inline fun <T> Iterable<T>.atMostOne(predicate: (T) -> Boolean): T? = this.filter(predicate).atMostOne()
|
||||
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.backend.common
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.incremental.components.LookupLocation
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
||||
import org.jetbrains.kotlin.resolve.scopes.MemberScopeImpl
|
||||
import org.jetbrains.kotlin.utils.Printer
|
||||
|
||||
class SimpleMemberScope(val members: List<DeclarationDescriptor>) : MemberScopeImpl() {
|
||||
|
||||
override fun getContributedClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? =
|
||||
members.filterIsInstance<ClassifierDescriptor>()
|
||||
.atMostOne { it.name == name }
|
||||
|
||||
override fun getContributedVariables(name: Name, location: LookupLocation): Collection<PropertyDescriptor> =
|
||||
members.filterIsInstance<PropertyDescriptor>()
|
||||
.filter { it.name == name }
|
||||
|
||||
override fun getContributedFunctions(name: Name, location: LookupLocation): Collection<SimpleFunctionDescriptor> =
|
||||
members.filterIsInstance<SimpleFunctionDescriptor>()
|
||||
.filter { it.name == name }
|
||||
|
||||
override fun getContributedDescriptors(
|
||||
kindFilter: DescriptorKindFilter,
|
||||
nameFilter: (Name) -> Boolean
|
||||
): Collection<DeclarationDescriptor> =
|
||||
members.filter { kindFilter.accepts(it) && nameFilter(it.name) }
|
||||
|
||||
override fun printScopeStructure(p: Printer) = TODO("not implemented")
|
||||
}
|
||||
@@ -65,8 +65,7 @@ import static org.jetbrains.kotlin.codegen.CodegenUtilKt.isToArrayFromCollection
|
||||
import static org.jetbrains.kotlin.codegen.JvmCodegenUtil.isConstOrHasJvmFieldAnnotation;
|
||||
import static org.jetbrains.kotlin.codegen.JvmCodegenUtil.isJvmInterface;
|
||||
import static org.jetbrains.kotlin.resolve.DescriptorUtils.*;
|
||||
import static org.jetbrains.kotlin.resolve.inline.InlineOnlyKt.isInlineOnlyPrivateInBytecode;
|
||||
import static org.jetbrains.kotlin.resolve.inline.InlineOnlyKt.isInlineWithReified;
|
||||
import static org.jetbrains.kotlin.resolve.inline.InlineOnlyKt.isEffectivelyInlineOnly;
|
||||
import static org.jetbrains.kotlin.resolve.jvm.AsmTypes.*;
|
||||
import static org.jetbrains.kotlin.resolve.jvm.annotations.JvmAnnotationUtilKt.hasJvmDefaultAnnotation;
|
||||
import static org.jetbrains.kotlin.resolve.jvm.annotations.JvmAnnotationUtilKt.hasJvmSyntheticAnnotation;
|
||||
@@ -389,8 +388,7 @@ public class AsmUtil {
|
||||
flags |= getVarargsFlag(functionDescriptor);
|
||||
flags |= getDeprecatedAccessFlag(functionDescriptor);
|
||||
if (deprecationResolver.isDeprecatedHidden(functionDescriptor) ||
|
||||
isInlineWithReified(functionDescriptor) ||
|
||||
functionDescriptor.isSuspend() && functionDescriptor.getVisibility().equals(Visibilities.PRIVATE)) {
|
||||
(functionDescriptor.isSuspend()) && functionDescriptor.getVisibility().equals(Visibilities.PRIVATE)) {
|
||||
flags |= ACC_SYNTHETIC;
|
||||
}
|
||||
return flags;
|
||||
@@ -528,7 +526,7 @@ public class AsmUtil {
|
||||
return ACC_PRIVATE;
|
||||
}
|
||||
|
||||
if (isInlineOnlyPrivateInBytecode(memberDescriptor)) {
|
||||
if (isEffectivelyInlineOnly(memberDescriptor)) {
|
||||
return ACC_PRIVATE;
|
||||
}
|
||||
|
||||
|
||||
@@ -195,7 +195,7 @@ public abstract class ClassBodyCodegen extends MemberCodegen<KtPureClassOrObject
|
||||
);
|
||||
}
|
||||
else {
|
||||
propertyCodegen.generatePrimaryConstructorProperty(propertyDescriptor);
|
||||
propertyCodegen.generatePrimaryConstructorProperty(p, propertyDescriptor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,6 @@ class CodeFragmentCodegenInfo(
|
||||
interface IParameter {
|
||||
val targetDescriptor: DeclarationDescriptor
|
||||
val targetType: KotlinType
|
||||
val isLValue: Boolean
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,18 +63,7 @@ class CodeFragmentCodegen private constructor(
|
||||
|
||||
override fun generateBody() {
|
||||
genConstructor()
|
||||
|
||||
val methodContext = object : MethodContext(methodDescriptor, classContext.contextKind, classContext, null, false) {
|
||||
override fun <D : CallableMemberDescriptor> getAccessorForSuperCallIfNeeded(
|
||||
descriptor: D,
|
||||
superCallTarget: ClassDescriptor?,
|
||||
state: GenerationState
|
||||
): D {
|
||||
return descriptor
|
||||
}
|
||||
}
|
||||
|
||||
genMethod(methodContext)
|
||||
genMethod(classContext.intoFunction(methodDescriptor))
|
||||
}
|
||||
|
||||
override fun generateKotlinMetadataAnnotation() {
|
||||
@@ -176,10 +164,6 @@ class CodeFragmentCodegen private constructor(
|
||||
codeFragment.putUserData(INFO_USERDATA_KEY, info)
|
||||
}
|
||||
|
||||
fun clearCodeFragmentInfo(codeFragment: KtCodeFragment) {
|
||||
codeFragment.putUserData(INFO_USERDATA_KEY, null)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getCodeFragmentInfo(codeFragment: KtCodeFragment): CodeFragmentCodegenInfo {
|
||||
return codeFragment.getUserData(INFO_USERDATA_KEY) ?: error("Codegen info user data is not set")
|
||||
@@ -215,7 +199,7 @@ class CodeFragmentCodegen private constructor(
|
||||
val asmType: Type
|
||||
val stackValue: StackValue
|
||||
|
||||
val sharedAsmType = getSharedTypeIfApplicable(parameter, typeMapper)
|
||||
val sharedAsmType = getSharedTypeIfApplicable(parameter.targetDescriptor, typeMapper)
|
||||
if (sharedAsmType != null) {
|
||||
asmType = sharedAsmType
|
||||
val unwrappedType = typeMapper.mapType(parameter.targetType)
|
||||
@@ -234,15 +218,9 @@ class CodeFragmentCodegen private constructor(
|
||||
return CalculatedCodeFragmentCodegenInfo(parameters, methodSignature.returnType)
|
||||
}
|
||||
|
||||
fun getSharedTypeIfApplicable(parameter: IParameter, typeMapper: KotlinTypeMapper): Type? {
|
||||
return when (val descriptor = parameter.targetDescriptor) {
|
||||
is LocalVariableDescriptor -> {
|
||||
var result = typeMapper.getSharedVarType(descriptor)
|
||||
if (result == null && parameter.isLValue) {
|
||||
result = StackValue.sharedTypeForType(typeMapper.mapType(descriptor.type))
|
||||
}
|
||||
result
|
||||
}
|
||||
fun getSharedTypeIfApplicable(descriptor: DeclarationDescriptor, typeMapper: KotlinTypeMapper): Type? {
|
||||
return when (descriptor) {
|
||||
is LocalVariableDescriptor -> typeMapper.getSharedVarType(descriptor)
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ public class ConstructorCodegen {
|
||||
ConstructorContext constructorContext = context.intoConstructor(constructorDescriptor, typeMapper);
|
||||
|
||||
functionCodegen.generateMethod(
|
||||
JvmDeclarationOriginKt.OtherOrigin(constructorDescriptor),
|
||||
JvmDeclarationOriginKt.OtherOrigin(constructor, constructorDescriptor),
|
||||
constructorDescriptor, constructorContext,
|
||||
new FunctionGenerationStrategy.CodegenBased(state) {
|
||||
@Override
|
||||
|
||||
@@ -76,7 +76,6 @@ import static org.jetbrains.kotlin.descriptors.ModalityKt.isOverridable;
|
||||
import static org.jetbrains.kotlin.resolve.DescriptorToSourceUtils.getSourceFromDescriptor;
|
||||
import static org.jetbrains.kotlin.resolve.DescriptorUtils.*;
|
||||
import static org.jetbrains.kotlin.resolve.inline.InlineOnlyKt.isEffectivelyInlineOnly;
|
||||
import static org.jetbrains.kotlin.resolve.inline.InlineOnlyKt.isInlineOnlyPrivateInBytecode;
|
||||
import static org.jetbrains.kotlin.resolve.jvm.AsmTypes.OBJECT_TYPE;
|
||||
import static org.jetbrains.kotlin.resolve.jvm.InlineClassManglingRulesKt.shouldHideConstructorDueToInlineClassTypeValueParameters;
|
||||
import static org.jetbrains.kotlin.resolve.jvm.annotations.JvmAnnotationUtilKt.hasJvmDefaultAnnotation;
|
||||
@@ -1154,10 +1153,10 @@ public class FunctionCodegen {
|
||||
|
||||
// $default methods are never private to be accessible from other class files (e.g. inner) without the need of synthetic accessors
|
||||
// $default methods are never protected to be accessible from subclass nested classes
|
||||
int visibilityFlag =
|
||||
Visibilities.isPrivate(functionDescriptor.getVisibility()) || isInlineOnlyPrivateInBytecode(functionDescriptor)
|
||||
? AsmUtil.NO_FLAG_PACKAGE_PRIVATE : Opcodes.ACC_PUBLIC;
|
||||
int flags = visibilityFlag | getDeprecatedAccessFlag(functionDescriptor) | ACC_SYNTHETIC;
|
||||
int visibilityFlag = Visibilities.isPrivate(functionDescriptor.getVisibility()) ||
|
||||
isEffectivelyInlineOnly(functionDescriptor) ?
|
||||
AsmUtil.NO_FLAG_PACKAGE_PRIVATE : Opcodes.ACC_PUBLIC;
|
||||
int flags = visibilityFlag | getDeprecatedAccessFlag(functionDescriptor) | ACC_SYNTHETIC;
|
||||
if (!(functionDescriptor instanceof ConstructorDescriptor &&
|
||||
!InlineClassesUtilsKt.isInlineClass(functionDescriptor.getContainingDeclaration()))
|
||||
) {
|
||||
|
||||
@@ -10,8 +10,6 @@ import org.jetbrains.kotlin.codegen.state.GenerationState
|
||||
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.PropertyAccessorDescriptor
|
||||
import org.jetbrains.kotlin.load.java.descriptors.JavaForKotlinOverridePropertyDescriptor
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.jvm.annotations.hasJvmDefaultAnnotation
|
||||
import org.jetbrains.kotlin.resolve.jvm.annotations.hasPlatformDependentAnnotation
|
||||
@@ -44,27 +42,18 @@ class DescriptorBasedFunctionHandleForJvm(
|
||||
override val mightBeIncorrectCode: Boolean
|
||||
get() = state.classBuilderMode.mightBeIncorrectCode
|
||||
|
||||
override fun hashCode(): Int =
|
||||
(descriptor.containerEntityForEqualityAndHashCode().hashCode() * 31 +
|
||||
descriptor.isJavaForKotlinOverrideProperty.hashCode()) * 31 +
|
||||
asmMethod.hashCode()
|
||||
|
||||
override fun hashCode(): Int = descriptor.containerEntityForEqualityAndHashCode().hashCode() + 31 * asmMethod.hashCode()
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (other !is DescriptorBasedFunctionHandleForJvm) return false
|
||||
|
||||
return other is DescriptorBasedFunctionHandleForJvm &&
|
||||
asmMethod == other.asmMethod &&
|
||||
descriptor.containerEntityForEqualityAndHashCode() == other.descriptor.containerEntityForEqualityAndHashCode() &&
|
||||
descriptor.isJavaForKotlinOverrideProperty == other.descriptor.isJavaForKotlinOverrideProperty
|
||||
return asmMethod == other.asmMethod &&
|
||||
descriptor.containerEntityForEqualityAndHashCode() == other.descriptor.containerEntityForEqualityAndHashCode()
|
||||
}
|
||||
}
|
||||
|
||||
private fun FunctionDescriptor.containerEntityForEqualityAndHashCode(): Any =
|
||||
(containingDeclaration as? ClassDescriptor)?.typeConstructor ?: containingDeclaration
|
||||
|
||||
private val FunctionDescriptor.isJavaForKotlinOverrideProperty: Boolean
|
||||
get() = this is PropertyAccessorDescriptor && correspondingProperty is JavaForKotlinOverridePropertyDescriptor
|
||||
|
||||
private fun CallableMemberDescriptor.isJvmDefaultOrPlatformDependent() =
|
||||
hasJvmDefaultAnnotation() || hasPlatformDependentAnnotation()
|
||||
|
||||
|
||||
@@ -472,38 +472,21 @@ public abstract class MemberCodegen<T extends KtPureElement/* TODO: & KtDeclarat
|
||||
return clInit;
|
||||
}
|
||||
|
||||
private boolean nopSeparatorNeeded = false;
|
||||
|
||||
private void generateNopSeparatorIfNeeded(NotNullLazyValue<ExpressionCodegen> codegen) {
|
||||
if (nopSeparatorNeeded) {
|
||||
nopSeparatorNeeded = false;
|
||||
codegen.invoke().v.nop();
|
||||
}
|
||||
}
|
||||
|
||||
protected void generateInitializers(@NotNull Function0<ExpressionCodegen> createCodegen) {
|
||||
NotNullLazyValue<ExpressionCodegen> codegen = LockBasedStorageManager.NO_LOCKS.createLazyValue(createCodegen);
|
||||
|
||||
for (KtDeclaration declaration : ((KtDeclarationContainer) element).getDeclarations()) {
|
||||
if (declaration instanceof KtProperty) {
|
||||
if (shouldInitializeProperty((KtProperty) declaration)) {
|
||||
generateNopSeparatorIfNeeded(codegen);
|
||||
initializeProperty(codegen.invoke(), (KtProperty) declaration);
|
||||
}
|
||||
}
|
||||
else if (declaration instanceof KtDestructuringDeclaration) {
|
||||
generateNopSeparatorIfNeeded(codegen);
|
||||
codegen.invoke().initializeDestructuringDeclaration((KtDestructuringDeclaration) declaration, true);
|
||||
}
|
||||
else if (declaration instanceof KtAnonymousInitializer) {
|
||||
KtExpression body = ((KtAnonymousInitializer) declaration).getBody();
|
||||
if (body != null) {
|
||||
generateNopSeparatorIfNeeded(codegen);
|
||||
|
||||
ExpressionCodegen expressionCodegen = codegen.invoke();
|
||||
expressionCodegen.gen(body, Type.VOID_TYPE);
|
||||
expressionCodegen.markLineNumber(declaration, true);
|
||||
nopSeparatorNeeded = true;
|
||||
codegen.invoke().gen(body, Type.VOID_TYPE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,24 +106,17 @@ public class PropertyCodegen {
|
||||
);
|
||||
}
|
||||
|
||||
if (!UnderscoreUtilKt.isSingleUnderscore(entry)) {
|
||||
genDestructuringDeclaration((PropertyDescriptor) variableDescriptor);
|
||||
}
|
||||
PropertyDescriptor propertyDescriptor = (PropertyDescriptor) variableDescriptor;
|
||||
genDestructuringDeclaration(entry, propertyDescriptor);
|
||||
}
|
||||
|
||||
public void generateInPackageFacade(@NotNull DeserializedPropertyDescriptor deserializedProperty) {
|
||||
assert context instanceof MultifileClassFacadeContext : "should be called only for generating facade: " + context;
|
||||
|
||||
genBackingFieldAndAnnotations(deserializedProperty);
|
||||
|
||||
if (!isConstOrHasJvmFieldAnnotation(deserializedProperty)) {
|
||||
generateGetter(deserializedProperty, null);
|
||||
generateSetter(deserializedProperty, null);
|
||||
}
|
||||
gen(null, deserializedProperty, null, null);
|
||||
}
|
||||
|
||||
private void gen(
|
||||
@NotNull KtProperty declaration,
|
||||
@Nullable KtProperty declaration,
|
||||
@NotNull PropertyDescriptor descriptor,
|
||||
@Nullable KtPropertyAccessor getter,
|
||||
@Nullable KtPropertyAccessor setter
|
||||
@@ -132,15 +125,15 @@ public class PropertyCodegen {
|
||||
kind == OwnerKind.DEFAULT_IMPLS || kind == OwnerKind.ERASED_INLINE_CLASS
|
||||
: "Generating property with a wrong kind (" + kind + "): " + descriptor;
|
||||
|
||||
genBackingFieldAndAnnotations(descriptor);
|
||||
genBackingFieldAndAnnotations(declaration, descriptor);
|
||||
|
||||
boolean isDefaultGetterAndSetter = isDefaultAccessor(getter) && isDefaultAccessor(setter);
|
||||
|
||||
if (isAccessorNeeded(declaration, descriptor, getter, isDefaultGetterAndSetter)) {
|
||||
generateGetter(descriptor, getter);
|
||||
generateGetter(declaration, descriptor, getter);
|
||||
}
|
||||
if (isAccessorNeeded(declaration, descriptor, setter, isDefaultGetterAndSetter)) {
|
||||
generateSetter(descriptor, setter);
|
||||
generateSetter(declaration, descriptor, setter);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,23 +141,29 @@ public class PropertyCodegen {
|
||||
return accessor == null || !accessor.hasBody();
|
||||
}
|
||||
|
||||
private void genDestructuringDeclaration(@NotNull PropertyDescriptor descriptor) {
|
||||
private void genDestructuringDeclaration(
|
||||
@NotNull KtDestructuringDeclarationEntry entry,
|
||||
@NotNull PropertyDescriptor descriptor
|
||||
) {
|
||||
assert kind == OwnerKind.PACKAGE || kind == OwnerKind.IMPLEMENTATION || kind == OwnerKind.DEFAULT_IMPLS
|
||||
: "Generating property with a wrong kind (" + kind + "): " + descriptor;
|
||||
|
||||
genBackingFieldAndAnnotations(descriptor);
|
||||
if (UnderscoreUtilKt.isSingleUnderscore(entry)) return;
|
||||
|
||||
generateGetter(descriptor, null);
|
||||
generateSetter(descriptor, null);
|
||||
genBackingFieldAndAnnotations(entry, descriptor);
|
||||
|
||||
generateGetter(entry, descriptor, null);
|
||||
generateSetter(entry, descriptor, null);
|
||||
}
|
||||
|
||||
private void genBackingFieldAndAnnotations(@NotNull PropertyDescriptor descriptor) {
|
||||
private void genBackingFieldAndAnnotations(@Nullable KtNamedDeclaration declaration, @NotNull PropertyDescriptor descriptor) {
|
||||
// Fields and '$annotations' methods for non-private const properties are generated in the multi-file facade
|
||||
boolean isBackingFieldOwner = descriptor.isConst() && !Visibilities.isPrivate(descriptor.getVisibility())
|
||||
? !(context instanceof MultifileClassPartContext)
|
||||
: CodegenContextUtil.isImplementationOwner(context, descriptor);
|
||||
|
||||
generateBackingField(descriptor, isBackingFieldOwner);
|
||||
assert declaration != null : "Declaration is null: " + descriptor + " (context=" + context + ")";
|
||||
generateBackingField(declaration, descriptor, isBackingFieldOwner);
|
||||
generateSyntheticMethodIfNeeded(descriptor, isBackingFieldOwner);
|
||||
}
|
||||
|
||||
@@ -175,7 +174,7 @@ public class PropertyCodegen {
|
||||
* @see JvmCodegenUtil#couldUseDirectAccessToProperty
|
||||
*/
|
||||
private boolean isAccessorNeeded(
|
||||
@NotNull KtProperty declaration,
|
||||
@Nullable KtProperty declaration,
|
||||
@NotNull PropertyDescriptor descriptor,
|
||||
@Nullable KtPropertyAccessor accessor,
|
||||
boolean isDefaultGetterAndSetter
|
||||
@@ -187,6 +186,8 @@ public class PropertyCodegen {
|
||||
// Don't generate accessors for interface properties with default accessors in DefaultImpls
|
||||
if (kind == OwnerKind.DEFAULT_IMPLS && isDefaultAccessor) return false;
|
||||
|
||||
if (declaration == null) return true;
|
||||
|
||||
// Delegated or extension properties can only be referenced via accessors
|
||||
if (declaration.hasDelegate() || declaration.getReceiverTypeReference() != null) return true;
|
||||
|
||||
@@ -202,7 +203,7 @@ public class PropertyCodegen {
|
||||
}
|
||||
|
||||
// Non-const properties from multifile classes have accessors regardless of visibility
|
||||
if (isTopLevelPropertyInMultifileClass(declaration, descriptor)) return true;
|
||||
if (isNonConstTopLevelPropertyInMultifileClass(declaration, descriptor)) return true;
|
||||
|
||||
// Private class properties have accessors only in cases when those accessors are non-trivial
|
||||
if (Visibilities.isPrivate(descriptor.getVisibility())) {
|
||||
@@ -211,7 +212,6 @@ public class PropertyCodegen {
|
||||
|
||||
// Non-private properties with private setter should not be generated for trivial properties
|
||||
// as the class will use direct field access instead
|
||||
//noinspection ConstantConditions
|
||||
if (accessor != null && accessor.isSetter() && Visibilities.isPrivate(descriptor.getSetter().getVisibility())) {
|
||||
return !isDefaultAccessor;
|
||||
}
|
||||
@@ -219,11 +219,12 @@ public class PropertyCodegen {
|
||||
return true;
|
||||
}
|
||||
|
||||
private static boolean isTopLevelPropertyInMultifileClass(
|
||||
private static boolean isNonConstTopLevelPropertyInMultifileClass(
|
||||
@NotNull KtProperty declaration,
|
||||
@NotNull PropertyDescriptor descriptor
|
||||
) {
|
||||
return descriptor.getContainingDeclaration() instanceof PackageFragmentDescriptor &&
|
||||
return !descriptor.isConst() &&
|
||||
descriptor.getContainingDeclaration() instanceof PackageFragmentDescriptor &&
|
||||
JvmFileClassUtilKt.isInsideJvmMultifileClassFile(declaration);
|
||||
}
|
||||
|
||||
@@ -243,12 +244,12 @@ public class PropertyCodegen {
|
||||
}
|
||||
}
|
||||
|
||||
public void generatePrimaryConstructorProperty(@NotNull PropertyDescriptor descriptor) {
|
||||
genBackingFieldAndAnnotations(descriptor);
|
||||
public void generatePrimaryConstructorProperty(@NotNull KtParameter parameter, @NotNull PropertyDescriptor descriptor) {
|
||||
genBackingFieldAndAnnotations(parameter, descriptor);
|
||||
|
||||
if (areAccessorsNeededForPrimaryConstructorProperty(descriptor, context.getContextKind())) {
|
||||
generateGetter(descriptor, null);
|
||||
generateSetter(descriptor, null);
|
||||
generateGetter(parameter, descriptor, null);
|
||||
generateSetter(parameter, descriptor, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -311,14 +312,17 @@ public class PropertyCodegen {
|
||||
return null;
|
||||
}
|
||||
|
||||
private void generateBackingField(@NotNull PropertyDescriptor descriptor, boolean isBackingFieldOwner) {
|
||||
private void generateBackingField(
|
||||
@NotNull KtNamedDeclaration p,
|
||||
@NotNull PropertyDescriptor descriptor,
|
||||
boolean isBackingFieldOwner
|
||||
) {
|
||||
if (isJvmInterface(descriptor.getContainingDeclaration()) || kind == OwnerKind.DEFAULT_IMPLS ||
|
||||
kind == OwnerKind.ERASED_INLINE_CLASS) {
|
||||
return;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
boolean isDelegate = descriptor.isDelegated();
|
||||
boolean isDelegate = p instanceof KtProperty && ((KtProperty) p).hasDelegate();
|
||||
|
||||
Object defaultValue;
|
||||
if (isDelegate) {
|
||||
@@ -337,7 +341,7 @@ public class PropertyCodegen {
|
||||
return;
|
||||
}
|
||||
|
||||
generateBackingField(descriptor, isDelegate, defaultValue, isBackingFieldOwner);
|
||||
generateBackingField(p, descriptor, isDelegate, defaultValue, isBackingFieldOwner);
|
||||
}
|
||||
|
||||
// Annotations on properties are stored in bytecode on an empty synthetic method. This way they're still
|
||||
@@ -360,6 +364,7 @@ public class PropertyCodegen {
|
||||
}
|
||||
|
||||
private void generateBackingField(
|
||||
@NotNull KtNamedDeclaration element,
|
||||
@NotNull PropertyDescriptor propertyDescriptor,
|
||||
boolean isDelegate,
|
||||
@Nullable Object defaultValue,
|
||||
@@ -385,7 +390,8 @@ public class PropertyCodegen {
|
||||
modifiers |= ACC_SYNTHETIC;
|
||||
}
|
||||
|
||||
KotlinType kotlinType = isDelegate ? getDelegateTypeForProperty(propertyDescriptor, bindingContext) : propertyDescriptor.getType();
|
||||
KotlinType kotlinType = isDelegate ? getDelegateTypeForProperty((KtProperty) element, propertyDescriptor, bindingContext)
|
||||
: propertyDescriptor.getType();
|
||||
Type type = typeMapper.mapType(kotlinType);
|
||||
|
||||
ClassBuilder builder = v;
|
||||
@@ -413,7 +419,7 @@ public class PropertyCodegen {
|
||||
|
||||
if (isBackingFieldOwner) {
|
||||
FieldVisitor fv = builder.newField(
|
||||
JvmDeclarationOriginKt.OtherOrigin(propertyDescriptor), modifiers, name, type.getDescriptor(),
|
||||
JvmDeclarationOriginKt.OtherOrigin(element, propertyDescriptor), modifiers, name, type.getDescriptor(),
|
||||
isDelegate ? null : typeMapper.mapFieldSignature(kotlinType, propertyDescriptor), defaultValue
|
||||
);
|
||||
|
||||
@@ -425,25 +431,22 @@ public class PropertyCodegen {
|
||||
|
||||
@NotNull
|
||||
public static KotlinType getDelegateTypeForProperty(
|
||||
@NotNull KtProperty p,
|
||||
@NotNull PropertyDescriptor propertyDescriptor,
|
||||
@NotNull BindingContext bindingContext
|
||||
) {
|
||||
KotlinType delegateType = null;
|
||||
|
||||
ResolvedCall<FunctionDescriptor> provideDelegateResolvedCall =
|
||||
bindingContext.get(BindingContext.PROVIDE_DELEGATE_RESOLVED_CALL, propertyDescriptor);
|
||||
KtExpression delegateExpression = p.getDelegateExpression();
|
||||
|
||||
KtProperty property = (KtProperty) DescriptorToSourceUtils.descriptorToDeclaration(propertyDescriptor);
|
||||
KtExpression delegateExpression = property != null ? property.getDelegateExpression() : null;
|
||||
|
||||
KotlinType delegateType;
|
||||
if (provideDelegateResolvedCall != null) {
|
||||
delegateType = provideDelegateResolvedCall.getResultingDescriptor().getReturnType();
|
||||
}
|
||||
else if (delegateExpression != null) {
|
||||
delegateType = bindingContext.getType(delegateExpression);
|
||||
}
|
||||
else {
|
||||
delegateType = null;
|
||||
}
|
||||
|
||||
if (delegateType == null) {
|
||||
// Delegation convention is unresolved
|
||||
@@ -466,49 +469,51 @@ public class PropertyCodegen {
|
||||
return false;
|
||||
}
|
||||
|
||||
private void generateGetter(@NotNull PropertyDescriptor descriptor, @Nullable KtPropertyAccessor getter) {
|
||||
generateAccessor(
|
||||
getter,
|
||||
descriptor.getGetter() != null ? descriptor.getGetter() : DescriptorFactory.createDefaultGetter(
|
||||
descriptor, Annotations.Companion.getEMPTY()
|
||||
)
|
||||
);
|
||||
private void generateGetter(
|
||||
@Nullable KtNamedDeclaration p, @NotNull PropertyDescriptor descriptor, @Nullable KtPropertyAccessor getter
|
||||
) {
|
||||
generateAccessor(p, getter, descriptor.getGetter() != null
|
||||
? descriptor.getGetter()
|
||||
: DescriptorFactory.createDefaultGetter(descriptor, Annotations.Companion.getEMPTY()));
|
||||
}
|
||||
|
||||
private void generateSetter(@NotNull PropertyDescriptor descriptor, @Nullable KtPropertyAccessor setter) {
|
||||
private void generateSetter(
|
||||
@Nullable KtNamedDeclaration p, @NotNull PropertyDescriptor descriptor, @Nullable KtPropertyAccessor setter
|
||||
) {
|
||||
if (!descriptor.isVar()) return;
|
||||
|
||||
generateAccessor(
|
||||
setter,
|
||||
descriptor.getSetter() != null ? descriptor.getSetter() : DescriptorFactory.createDefaultSetter(
|
||||
descriptor, Annotations.Companion.getEMPTY(), Annotations.Companion.getEMPTY()
|
||||
)
|
||||
);
|
||||
generateAccessor(p, setter, descriptor.getSetter() != null
|
||||
? descriptor.getSetter()
|
||||
: DescriptorFactory.createDefaultSetter(
|
||||
descriptor, Annotations.Companion.getEMPTY(), Annotations.Companion.getEMPTY()
|
||||
));
|
||||
}
|
||||
|
||||
private void generateAccessor(@Nullable KtPropertyAccessor accessor, @NotNull PropertyAccessorDescriptor descriptor) {
|
||||
private void generateAccessor(
|
||||
@Nullable KtNamedDeclaration p,
|
||||
@Nullable KtPropertyAccessor accessor,
|
||||
@NotNull PropertyAccessorDescriptor accessorDescriptor
|
||||
) {
|
||||
if (context instanceof MultifileClassFacadeContext &&
|
||||
(Visibilities.isPrivate(descriptor.getVisibility()) ||
|
||||
AsmUtil.getVisibilityAccessFlag(descriptor) == Opcodes.ACC_PRIVATE)) {
|
||||
(Visibilities.isPrivate(accessorDescriptor.getVisibility()) ||
|
||||
AsmUtil.getVisibilityAccessFlag(accessorDescriptor) == Opcodes.ACC_PRIVATE)) {
|
||||
return;
|
||||
}
|
||||
|
||||
FunctionGenerationStrategy strategy;
|
||||
if (accessor == null || !accessor.hasBody()) {
|
||||
@SuppressWarnings("deprecation")
|
||||
boolean isDelegated = descriptor.getCorrespondingProperty().isDelegated();
|
||||
if (isDelegated) {
|
||||
strategy = new DelegatedPropertyAccessorStrategy(state, descriptor);
|
||||
if (p instanceof KtProperty && ((KtProperty) p).hasDelegate()) {
|
||||
strategy = new DelegatedPropertyAccessorStrategy(state, accessorDescriptor);
|
||||
}
|
||||
else {
|
||||
strategy = new DefaultPropertyAccessorStrategy(state, descriptor);
|
||||
strategy = new DefaultPropertyAccessorStrategy(state, accessorDescriptor);
|
||||
}
|
||||
}
|
||||
else {
|
||||
strategy = new FunctionGenerationStrategy.FunctionDefault(state, accessor);
|
||||
}
|
||||
|
||||
functionCodegen.generateMethod(JvmDeclarationOriginKt.OtherOrigin(descriptor), descriptor, strategy);
|
||||
functionCodegen.generateMethod(JvmDeclarationOriginKt.OtherOrigin(accessor != null ? accessor : p, accessorDescriptor), accessorDescriptor, strategy);
|
||||
}
|
||||
|
||||
private static class DefaultPropertyAccessorStrategy extends FunctionGenerationStrategy.CodegenBased {
|
||||
|
||||
@@ -27,7 +27,7 @@ import java.util.*;
|
||||
|
||||
import static org.jetbrains.kotlin.codegen.AsmUtil.getVisibilityAccessFlag;
|
||||
import static org.jetbrains.kotlin.codegen.JvmCodegenUtil.isNonDefaultInterfaceMember;
|
||||
import static org.jetbrains.kotlin.resolve.inline.InlineOnlyKt.isInlineOnlyPrivateInBytecode;
|
||||
import static org.jetbrains.kotlin.resolve.inline.InlineOnlyKt.isEffectivelyInlineOnly;
|
||||
import static org.jetbrains.kotlin.resolve.jvm.annotations.JvmAnnotationUtilKt.hasJvmDefaultAnnotation;
|
||||
import static org.jetbrains.kotlin.resolve.jvm.annotations.JvmAnnotationUtilKt.isCallableMemberWithJvmDefaultAnnotation;
|
||||
import static org.jetbrains.org.objectweb.asm.Opcodes.ACC_PRIVATE;
|
||||
@@ -693,7 +693,7 @@ public abstract class CodegenContext<T extends DeclarationDescriptor> {
|
||||
boolean withinInline,
|
||||
boolean isSuperCall
|
||||
) {
|
||||
if (isInlineOnlyPrivateInBytecode(unwrappedDescriptor)) return false;
|
||||
if (isEffectivelyInlineOnly(unwrappedDescriptor)) return false;
|
||||
|
||||
return isSuperCall && withinInline ||
|
||||
(accessFlag & ACC_PRIVATE) != 0 ||
|
||||
|
||||
@@ -995,7 +995,7 @@ private fun findSafelyReachableReturns(methodNode: MethodNode, sourceFrames: Arr
|
||||
|
||||
if (!insn.isMeaningful || insn.opcode in SAFE_OPCODES || insn.isInvisibleInDebugVarInsn(methodNode) ||
|
||||
isInlineMarker(insn)) {
|
||||
setOf<Int>()
|
||||
setOf()
|
||||
} else null
|
||||
}
|
||||
|
||||
|
||||
@@ -188,9 +188,23 @@ internal fun Type.boxReceiverForBoundReference() =
|
||||
internal fun Type.boxReceiverForBoundReference(kotlinType: KotlinType, typeMapper: KotlinTypeMapper) =
|
||||
AsmUtil.boxType(this, kotlinType, typeMapper)
|
||||
|
||||
abstract class ExpressionLambda(isCrossInline: Boolean) : LambdaInfo(isCrossInline) {
|
||||
abstract class ExpressionLambda(protected val typeMapper: KotlinTypeMapper, isCrossInline: Boolean) : LambdaInfo(isCrossInline) {
|
||||
|
||||
override fun generateLambdaBody(sourceCompiler: SourceCompilerForInline, reifiedTypeInliner: ReifiedTypeInliner) {
|
||||
node = sourceCompiler.generateLambdaBody(this)
|
||||
val jvmMethodSignature = typeMapper.mapSignatureSkipGeneric(invokeMethodDescriptor)
|
||||
val asmMethod = jvmMethodSignature.asmMethod
|
||||
val methodNode = MethodNode(
|
||||
Opcodes.API_VERSION, AsmUtil.getMethodAsmFlags(invokeMethodDescriptor, OwnerKind.IMPLEMENTATION, sourceCompiler.state),
|
||||
asmMethod.name, asmMethod.descriptor, null, null
|
||||
)
|
||||
|
||||
node = wrapWithMaxLocalCalc(methodNode).let { adapter ->
|
||||
val smap = sourceCompiler.generateLambdaBody(
|
||||
adapter, jvmMethodSignature, this
|
||||
)
|
||||
adapter.visitMaxs(-1, -1)
|
||||
SMAPAndMethodNode(methodNode, smap)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -200,7 +214,7 @@ class PsiExpressionLambda(
|
||||
languageVersionSettings: LanguageVersionSettings,
|
||||
isCrossInline: Boolean,
|
||||
override val isBoundCallableReference: Boolean
|
||||
) : ExpressionLambda(isCrossInline) {
|
||||
) : ExpressionLambda(typeMapper, isCrossInline) {
|
||||
|
||||
override val lambdaClassType: Type
|
||||
|
||||
|
||||
@@ -153,7 +153,7 @@ class MethodInliner(
|
||||
LocalVariablesSorter(
|
||||
resultNode.access,
|
||||
resultNode.desc,
|
||||
wrapWithMaxLocalCalc(resultNode)
|
||||
resultNode
|
||||
), AsmTypeRemapper(remapper, result)
|
||||
)
|
||||
|
||||
|
||||
@@ -48,7 +48,11 @@ interface SourceCompilerForInline {
|
||||
|
||||
val lazySourceMapper: DefaultSourceMapper
|
||||
|
||||
fun generateLambdaBody(lambdaInfo: ExpressionLambda): SMAPAndMethodNode
|
||||
fun generateLambdaBody(
|
||||
adapter: MethodVisitor,
|
||||
jvmMethodSignature: JvmMethodSignature,
|
||||
lambdaInfo: ExpressionLambda
|
||||
): SMAP
|
||||
|
||||
fun doCreateMethodNodeFromSource(
|
||||
callableDescriptor: FunctionDescriptor,
|
||||
@@ -129,16 +133,13 @@ class PsiSourceCompilerForInline(private val codegen: ExpressionCodegen, overrid
|
||||
override val lazySourceMapper
|
||||
get() = codegen.parentCodegen.orCreateSourceMapper
|
||||
|
||||
override fun generateLambdaBody(lambdaInfo: ExpressionLambda): SMAPAndMethodNode {
|
||||
override fun generateLambdaBody(
|
||||
adapter: MethodVisitor,
|
||||
jvmMethodSignature: JvmMethodSignature,
|
||||
lambdaInfo: ExpressionLambda
|
||||
): SMAP {
|
||||
lambdaInfo as? PsiExpressionLambda ?: error("TODO")
|
||||
val invokeMethodDescriptor = lambdaInfo.invokeMethodDescriptor
|
||||
val jvmMethodSignature = state.typeMapper.mapSignatureSkipGeneric(invokeMethodDescriptor)
|
||||
val asmMethod = jvmMethodSignature.asmMethod
|
||||
val methodNode = MethodNode(
|
||||
Opcodes.API_VERSION, AsmUtil.getMethodAsmFlags(invokeMethodDescriptor, OwnerKind.IMPLEMENTATION, state),
|
||||
asmMethod.name, asmMethod.descriptor, null, null
|
||||
)
|
||||
val adapter = wrapWithMaxLocalCalc(methodNode)
|
||||
val closureContext = when {
|
||||
lambdaInfo.isPropertyReference ->
|
||||
codegen.getContext().intoAnonymousClass(lambdaInfo.classDescriptor, codegen, OwnerKind.IMPLEMENTATION)
|
||||
@@ -149,13 +150,12 @@ class PsiSourceCompilerForInline(private val codegen: ExpressionCodegen, overrid
|
||||
else -> codegen.getContext().intoClosure(invokeMethodDescriptor, codegen, state.typeMapper)
|
||||
}
|
||||
val context = closureContext.intoInlinedLambda(invokeMethodDescriptor, lambdaInfo.isCrossInline, lambdaInfo.isPropertyReference)
|
||||
val smap = generateMethodBody(
|
||||
|
||||
return generateMethodBody(
|
||||
adapter, invokeMethodDescriptor, context,
|
||||
lambdaInfo.functionWithBodyOrCallableReference,
|
||||
jvmMethodSignature, lambdaInfo
|
||||
)
|
||||
adapter.visitMaxs(-1, -1)
|
||||
return SMAPAndMethodNode(methodNode, smap)
|
||||
}
|
||||
|
||||
private fun generateMethodBody(
|
||||
@@ -175,7 +175,7 @@ class PsiSourceCompilerForInline(private val codegen: ExpressionCodegen, overrid
|
||||
codegen.parentCodegen.className
|
||||
else
|
||||
state.typeMapper.mapImplementationOwner(descriptor).internalName,
|
||||
if (isLambda) emptyList<ClassDescriptor>() else additionalInnerClasses,
|
||||
if (isLambda) emptyList() else additionalInnerClasses,
|
||||
isLambda
|
||||
)
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ class JvmSerializerExtension(private val bindings: JvmSerializationBindings, sta
|
||||
versionRequirementTable: MutableVersionRequirementTable,
|
||||
childSerializer: DescriptorSerializer
|
||||
) {
|
||||
if (moduleName != JvmProtoBufUtil.DEFAULT_MODULE_NAME) {
|
||||
if (moduleName != JvmAbi.DEFAULT_MODULE_NAME) {
|
||||
proto.setExtension(JvmProtoBuf.classModuleName, stringTable.getStringIndex(moduleName))
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ class JvmSerializerExtension(private val bindings: JvmSerializationBindings, sta
|
||||
}
|
||||
|
||||
override fun serializePackage(packageFqName: FqName, proto: ProtoBuf.Package.Builder) {
|
||||
if (moduleName != JvmProtoBufUtil.DEFAULT_MODULE_NAME) {
|
||||
if (moduleName != JvmAbi.DEFAULT_MODULE_NAME) {
|
||||
proto.setExtension(JvmProtoBuf.packageModuleName, stringTable.getStringIndex(moduleName))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ package org.jetbrains.kotlin.codegen.signature
|
||||
import org.jetbrains.kotlin.codegen.ClassBuilderMode
|
||||
import org.jetbrains.kotlin.codegen.state.KotlinTypeMapper
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.metadata.jvm.deserialization.JvmProtoBufUtil
|
||||
import org.jetbrains.kotlin.load.java.JvmAbi
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.KotlinToJvmSignatureMapper
|
||||
|
||||
@@ -16,7 +16,7 @@ class KotlinToJvmSignatureMapperImpl : KotlinToJvmSignatureMapper {
|
||||
// We use empty BindingContext, because it is only used by KotlinTypeMapper for purposes irrelevant to the needs of this class
|
||||
private val typeMapper = KotlinTypeMapper(
|
||||
BindingContext.EMPTY, ClassBuilderMode.LIGHT_CLASSES,
|
||||
JvmProtoBufUtil.DEFAULT_MODULE_NAME,
|
||||
JvmAbi.DEFAULT_MODULE_NAME,
|
||||
KotlinTypeMapper.LANGUAGE_VERSION_SETTINGS_DEFAULT// TODO use proper LanguageVersionSettings
|
||||
)
|
||||
|
||||
|
||||
@@ -911,7 +911,7 @@ class KotlinTypeMapper @JvmOverloads constructor(
|
||||
val isConstructor = isConstructor(jvmSignature)
|
||||
val descriptor = getDefaultDescriptor(
|
||||
jvmSignature,
|
||||
if (isStaticMethod(kind, functionDescriptor) || isConstructor || (isIrBackend && isStaticDeclaration(functionDescriptor)))
|
||||
if (isStaticMethod(kind, functionDescriptor) || isStaticDeclaration(functionDescriptor) || isConstructor)
|
||||
null else ownerType.descriptor,
|
||||
functionDescriptor.unwrapFrontendVersion(),
|
||||
if (isIrBackend && isConstructor) {
|
||||
|
||||
@@ -8,7 +8,6 @@ dependencies {
|
||||
compile(project(":core:util.runtime"))
|
||||
compile(project(":compiler:frontend"))
|
||||
compile(project(":compiler:frontend.java"))
|
||||
compile(project(":js:js.frontend"))
|
||||
compileOnly(project(":kotlin-reflect-api"))
|
||||
compileOnly(intellijCoreDep()) { includeJars("intellij-core") }
|
||||
compileOnly(intellijDep()) { includeIntellijCoreJarDependencies(project) }
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
@file:Suppress("DEPRECATION_ERROR")
|
||||
|
||||
package org.jetbrains.kotlin.analyzer.common
|
||||
|
||||
import org.jetbrains.kotlin.platform.CommonPlatforms
|
||||
import org.jetbrains.kotlin.resolve.TargetPlatform
|
||||
|
||||
@Deprecated(
|
||||
message = "This class is deprecated and will be removed soon, use API from 'org.jetbrains.kotlin.platform.*' packages instead",
|
||||
replaceWith = ReplaceWith("CommonPlatforms.defaultCommonPlatform", "org.jetbrains.kotlin.platform.CommonPlatforms"),
|
||||
level = DeprecationLevel.ERROR
|
||||
)
|
||||
interface CommonPlatform : TargetPlatform {
|
||||
@JvmDefault
|
||||
override val platformName: String
|
||||
get() = "Default"
|
||||
|
||||
companion object {
|
||||
@JvmField
|
||||
val INSTANCE: CommonPlatform = CommonPlatforms.CompatCommonPlatform
|
||||
}
|
||||
}
|
||||
@@ -1,196 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.analyzer.common
|
||||
|
||||
import com.intellij.openapi.components.ServiceManager
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.psi.search.GlobalSearchScope
|
||||
import org.jetbrains.kotlin.analyzer.*
|
||||
import org.jetbrains.kotlin.config.LanguageFeature
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.container.StorageComponentContainer
|
||||
import org.jetbrains.kotlin.platform.TargetPlatformVersion
|
||||
import org.jetbrains.kotlin.container.get
|
||||
import org.jetbrains.kotlin.context.ModuleContext
|
||||
import org.jetbrains.kotlin.context.ProjectContext
|
||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.impl.CompositePackageFragmentProvider
|
||||
import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl
|
||||
import org.jetbrains.kotlin.container.useImpl
|
||||
import org.jetbrains.kotlin.container.useInstance
|
||||
import org.jetbrains.kotlin.frontend.di.configureModule
|
||||
import org.jetbrains.kotlin.frontend.di.configureStandardResolveComponents
|
||||
import org.jetbrains.kotlin.load.kotlin.MetadataFinderFactory
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.platform.CommonPlatforms
|
||||
import org.jetbrains.kotlin.platform.TargetPlatform
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.resolve.*
|
||||
import org.jetbrains.kotlin.resolve.checkers.ExpectedActualDeclarationChecker
|
||||
import org.jetbrains.kotlin.resolve.lazy.ResolveSession
|
||||
import org.jetbrains.kotlin.resolve.lazy.declarations.DeclarationProviderFactory
|
||||
import org.jetbrains.kotlin.resolve.lazy.declarations.DeclarationProviderFactoryService
|
||||
import org.jetbrains.kotlin.serialization.deserialization.MetadataPackageFragmentProvider
|
||||
import org.jetbrains.kotlin.serialization.deserialization.MetadataPartProvider
|
||||
|
||||
class CommonAnalysisParameters(
|
||||
val metadataPartProviderFactory: (ModuleContent<*>) -> MetadataPartProvider
|
||||
) : PlatformAnalysisParameters
|
||||
|
||||
/**
|
||||
* A facade that is used to analyze common (platform-independent) modules in multi-platform projects.
|
||||
* See [CommonPlatform]
|
||||
*/
|
||||
class CommonResolverForModuleFactory(private val shouldCheckExpectActual: Boolean) : ResolverForModuleFactory() {
|
||||
|
||||
override fun <M : ModuleInfo> createResolverForModule(
|
||||
moduleDescriptor: ModuleDescriptorImpl,
|
||||
moduleContext: ModuleContext,
|
||||
moduleContent: ModuleContent<M>,
|
||||
platformParameters: PlatformAnalysisParameters,
|
||||
targetEnvironment: TargetEnvironment,
|
||||
resolverForProject: ResolverForProject<M>,
|
||||
languageVersionSettings: LanguageVersionSettings
|
||||
): ResolverForModule {
|
||||
val (moduleInfo, syntheticFiles, moduleContentScope) = moduleContent
|
||||
val project = moduleContext.project
|
||||
val declarationProviderFactory = DeclarationProviderFactoryService.createDeclarationProviderFactory(
|
||||
project, moduleContext.storageManager, syntheticFiles,
|
||||
moduleContentScope,
|
||||
moduleInfo
|
||||
)
|
||||
|
||||
val metadataPartProvider = (platformParameters as CommonAnalysisParameters).metadataPartProviderFactory(moduleContent)
|
||||
val trace = CodeAnalyzerInitializer.getInstance(project).createTrace()
|
||||
val container = createContainerToResolveCommonCode(
|
||||
moduleContext, trace, declarationProviderFactory, moduleContentScope, targetEnvironment, metadataPartProvider,
|
||||
languageVersionSettings, CommonPlatforms.defaultCommonPlatform, CommonPlatformAnalyzerServices, shouldCheckExpectActual
|
||||
)
|
||||
|
||||
val packageFragmentProviders = listOf(
|
||||
container.get<ResolveSession>().packageFragmentProvider,
|
||||
container.get<MetadataPackageFragmentProvider>()
|
||||
)
|
||||
|
||||
return ResolverForModule(CompositePackageFragmentProvider(packageFragmentProviders), container)
|
||||
}
|
||||
|
||||
companion object {
|
||||
private class SourceModuleInfo(
|
||||
override val name: Name,
|
||||
override val capabilities: Map<ModuleDescriptor.Capability<*>, Any?>,
|
||||
private val dependOnOldBuiltIns: Boolean
|
||||
) : ModuleInfo {
|
||||
override fun dependencies() = listOf(this)
|
||||
|
||||
override fun dependencyOnBuiltIns(): ModuleInfo.DependencyOnBuiltIns =
|
||||
if (dependOnOldBuiltIns) ModuleInfo.DependencyOnBuiltIns.LAST else ModuleInfo.DependencyOnBuiltIns.NONE
|
||||
|
||||
override val platform: TargetPlatform
|
||||
get() = CommonPlatforms.defaultCommonPlatform
|
||||
|
||||
override val analyzerServices: PlatformDependentAnalyzerServices
|
||||
get() = CommonPlatformAnalyzerServices
|
||||
}
|
||||
|
||||
fun analyzeFiles(
|
||||
files: Collection<KtFile>, moduleName: Name, dependOnBuiltIns: Boolean, languageVersionSettings: LanguageVersionSettings,
|
||||
capabilities: Map<ModuleDescriptor.Capability<*>, Any?> = emptyMap(),
|
||||
shouldCheckExpectActual: Boolean = false,
|
||||
metadataPartProviderFactory: (ModuleContent<ModuleInfo>) -> MetadataPartProvider
|
||||
): AnalysisResult {
|
||||
val moduleInfo = SourceModuleInfo(moduleName, capabilities, dependOnBuiltIns)
|
||||
val project = files.firstOrNull()?.project ?: throw AssertionError("No files to analyze")
|
||||
|
||||
val multiplatformLanguageSettings = object : LanguageVersionSettings by languageVersionSettings {
|
||||
override fun getFeatureSupport(feature: LanguageFeature): LanguageFeature.State =
|
||||
if (feature == LanguageFeature.MultiPlatformProjects) LanguageFeature.State.ENABLED
|
||||
else languageVersionSettings.getFeatureSupport(feature)
|
||||
}
|
||||
|
||||
@Suppress("NAME_SHADOWING")
|
||||
val resolver = ResolverForProjectImpl(
|
||||
"sources for metadata serializer",
|
||||
ProjectContext(project, "metadata serializer"),
|
||||
listOf(moduleInfo),
|
||||
modulesContent = { ModuleContent(it, files, GlobalSearchScope.allScope(project)) },
|
||||
moduleLanguageSettingsProvider = object : LanguageSettingsProvider {
|
||||
override fun getLanguageVersionSettings(
|
||||
moduleInfo: ModuleInfo,
|
||||
project: Project,
|
||||
isReleaseCoroutines: Boolean?
|
||||
) = multiplatformLanguageSettings
|
||||
|
||||
override fun getTargetPlatform(
|
||||
moduleInfo: ModuleInfo,
|
||||
project: Project
|
||||
) = TargetPlatformVersion.NoVersion
|
||||
},
|
||||
resolverForModuleFactoryByPlatform = { CommonResolverForModuleFactory(shouldCheckExpectActual) },
|
||||
platformParameters = { _ -> CommonAnalysisParameters(metadataPartProviderFactory) }
|
||||
)
|
||||
|
||||
val moduleDescriptor = resolver.descriptorForModule(moduleInfo)
|
||||
val container = resolver.resolverForModule(moduleInfo).componentProvider
|
||||
|
||||
container.get<LazyTopDownAnalyzer>().analyzeDeclarations(TopDownAnalysisMode.TopLevelDeclarations, files)
|
||||
|
||||
return AnalysisResult.success(container.get<BindingTrace>().bindingContext, moduleDescriptor)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun createContainerToResolveCommonCode(
|
||||
moduleContext: ModuleContext,
|
||||
bindingTrace: BindingTrace,
|
||||
declarationProviderFactory: DeclarationProviderFactory,
|
||||
moduleContentScope: GlobalSearchScope,
|
||||
targetEnvironment: TargetEnvironment,
|
||||
metadataPartProvider: MetadataPartProvider,
|
||||
languageVersionSettings: LanguageVersionSettings,
|
||||
platform: TargetPlatform,
|
||||
analyzerServices: PlatformDependentAnalyzerServices,
|
||||
shouldCheckExpectActual: Boolean
|
||||
): StorageComponentContainer =
|
||||
createContainer("ResolveCommonCode", analyzerServices) {
|
||||
configureModule(moduleContext, platform, analyzerServices, bindingTrace, languageVersionSettings)
|
||||
|
||||
useInstance(moduleContentScope)
|
||||
useInstance(declarationProviderFactory)
|
||||
|
||||
configureStandardResolveComponents()
|
||||
|
||||
configureCommonSpecificComponents()
|
||||
useInstance(metadataPartProvider)
|
||||
|
||||
val metadataFinderFactory = ServiceManager.getService(
|
||||
moduleContext.project,
|
||||
MetadataFinderFactory::class.java
|
||||
)
|
||||
?: error("No MetadataFinderFactory in project")
|
||||
useInstance(metadataFinderFactory.create(moduleContentScope))
|
||||
|
||||
targetEnvironment.configure(this)
|
||||
|
||||
if (shouldCheckExpectActual) {
|
||||
useImpl<ExpectedActualDeclarationChecker>()
|
||||
}
|
||||
}
|
||||
|
||||
fun StorageComponentContainer.configureCommonSpecificComponents() {
|
||||
useImpl<MetadataPackageFragmentProvider>()
|
||||
}
|
||||
@@ -114,11 +114,6 @@ class K2JSCompilerArguments : CommonCompilerArguments() {
|
||||
)
|
||||
var irProduceOnly: String? by NullableStringFreezableVar(null)
|
||||
|
||||
@Argument(
|
||||
value = "-Xir-legacy-gradle-plugin-compatibility",
|
||||
description = "Make KLIB generation compatible with legacy gradle plugin"
|
||||
)
|
||||
var irLegacyGradlePluginCompatimbility: Boolean by FreezableVar(false)
|
||||
|
||||
@GradleOption(DefaultValues.BooleanTrueDefault::class)
|
||||
@Argument(value = "-Xtyped-arrays", description = "Translate primitive arrays to JS typed arrays")
|
||||
|
||||
@@ -96,11 +96,5 @@ open class AggregatedReplStageState<T1, T2>(val state1: IReplStageState<T1>, val
|
||||
override fun getNextLineNo() = state1.getNextLineNo()
|
||||
|
||||
override val currentGeneration: Int get() = state1.currentGeneration
|
||||
|
||||
override fun dispose() {
|
||||
state2.dispose()
|
||||
state1.dispose()
|
||||
super.dispose()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -60,21 +60,18 @@ open class BasicReplStageHistory<T>(override val lock: ReentrantReadWriteLock =
|
||||
|
||||
override fun resetTo(id: ILineId): Iterable<ILineId> {
|
||||
lock.write {
|
||||
return tryResetTo(id) ?: throw NoSuchElementException("Cannot reset to non-existent line ${id.no}")
|
||||
}
|
||||
}
|
||||
|
||||
protected fun tryResetTo(id: ILineId): List<ILineId>? {
|
||||
val idx = indexOfFirst { it.id == id }
|
||||
if (idx < 0) return null
|
||||
return if (idx < lastIndex) {
|
||||
val removed = asSequence().drop(idx + 1).map { it.id }.toList()
|
||||
removeRange(idx + 1, size)
|
||||
currentGeneration.incrementAndGet()
|
||||
removed
|
||||
} else {
|
||||
currentGeneration.incrementAndGet()
|
||||
emptyList()
|
||||
val idx = indexOfFirst { it.id == id }
|
||||
if (idx < 0) throw java.util.NoSuchElementException("Cannot rest to inexistent line ${id.no}")
|
||||
return if (idx < lastIndex) {
|
||||
val removed = asSequence().drop(idx + 1).map { it.id }.toList()
|
||||
removeRange(idx + 1, size)
|
||||
currentGeneration.incrementAndGet()
|
||||
removed
|
||||
}
|
||||
else {
|
||||
currentGeneration.incrementAndGet()
|
||||
emptyList()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,11 +20,13 @@ import java.io.File
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock
|
||||
import kotlin.concurrent.write
|
||||
|
||||
open class GenericReplCompilingEvaluatorBase(
|
||||
val compiler: ReplCompiler,
|
||||
val evaluator: ReplEvaluator,
|
||||
private val fallbackScriptArgs: ScriptArgsWithTypes? = null
|
||||
class GenericReplCompilingEvaluator(val compiler: ReplCompiler,
|
||||
baseClasspath: Iterable<File>,
|
||||
baseClassloader: ClassLoader? = Thread.currentThread().contextClassLoader,
|
||||
private val fallbackScriptArgs: ScriptArgsWithTypes? = null,
|
||||
repeatingMode: ReplRepeatingMode = ReplRepeatingMode.REPEAT_ONLY_MOST_RECENT
|
||||
) : ReplFullEvaluator {
|
||||
private val evaluator = GenericReplEvaluator(baseClasspath, baseClassloader, fallbackScriptArgs, repeatingMode)
|
||||
|
||||
override fun createState(lock: ReentrantReadWriteLock): IReplStageState<*> = AggregatedReplStageState(compiler.createState(lock), evaluator.createState(lock), lock)
|
||||
|
||||
@@ -73,7 +75,7 @@ open class GenericReplCompilingEvaluatorBase(
|
||||
}
|
||||
|
||||
override fun eval(state: IReplStageState<*>, compileResult: ReplCompileResult.CompiledClasses, scriptArgs: ScriptArgsWithTypes?, invokeWrapper: InvokeWrapper?): ReplEvalResult =
|
||||
evaluator.eval(state, compileResult, scriptArgs, invokeWrapper)
|
||||
evaluator.eval(state, compileResult, scriptArgs, invokeWrapper)
|
||||
|
||||
override fun check(state: IReplStageState<*>, codeLine: ReplCodeLine): ReplCheckResult = compiler.check(state, codeLine)
|
||||
|
||||
@@ -91,24 +93,12 @@ open class GenericReplCompilingEvaluatorBase(
|
||||
private val evaluator: ReplEvaluator,
|
||||
private val defaultScriptArgs: ScriptArgsWithTypes?) : Evaluable {
|
||||
override fun eval(scriptArgs: ScriptArgsWithTypes?, invokeWrapper: InvokeWrapper?): ReplEvalResult =
|
||||
evaluator.eval(state, compiledCode, scriptArgs ?: defaultScriptArgs, invokeWrapper)
|
||||
evaluator.eval(state, compiledCode, scriptArgs ?: defaultScriptArgs, invokeWrapper)
|
||||
}
|
||||
}
|
||||
|
||||
class GenericReplCompilingEvaluator(
|
||||
compiler: ReplCompiler,
|
||||
baseClasspath: Iterable<File>,
|
||||
baseClassloader: ClassLoader? = Thread.currentThread().contextClassLoader,
|
||||
fallbackScriptArgs: ScriptArgsWithTypes? = null,
|
||||
repeatingMode: ReplRepeatingMode = ReplRepeatingMode.REPEAT_ONLY_MOST_RECENT
|
||||
) : GenericReplCompilingEvaluatorBase(
|
||||
compiler,
|
||||
GenericReplEvaluator(baseClasspath, baseClassloader, fallbackScriptArgs, repeatingMode),
|
||||
fallbackScriptArgs
|
||||
)
|
||||
|
||||
private fun AggregatedReplStageState<*, *>.adjustHistories(): Iterable<ILineId>? =
|
||||
state2.history.peek()?.let {
|
||||
state1.history.resetTo(it.id)
|
||||
}
|
||||
state2.history.peek()?.let {
|
||||
state1.history.resetTo(it.id)
|
||||
}
|
||||
?: state1.history.reset()
|
||||
|
||||
@@ -90,8 +90,7 @@ sealed class ReplCompileResult : Serializable {
|
||||
val classes: List<CompiledClassData>,
|
||||
val hasResult: Boolean,
|
||||
val classpathAddendum: List<File>,
|
||||
val type: String?,
|
||||
val data: Any? // TODO: temporary; migration to new scripting infrastructure
|
||||
val type: String?
|
||||
) : ReplCompileResult() {
|
||||
companion object { private val serialVersionUID: Long = 2L }
|
||||
}
|
||||
|
||||
@@ -61,9 +61,6 @@ interface IReplStageState<T> {
|
||||
fun <StateT : IReplStageState<*>> asState(target: Class<out StateT>): StateT =
|
||||
if (target.isAssignableFrom(this::class.java)) this as StateT
|
||||
else throw IllegalArgumentException("$this is not an expected instance of IReplStageState")
|
||||
|
||||
fun dispose() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.platform
|
||||
|
||||
import org.jetbrains.kotlin.platform.js.JsPlatforms
|
||||
import org.jetbrains.kotlin.platform.js.JsPlatforms.defaultJsPlatform
|
||||
import org.jetbrains.kotlin.platform.jvm.JvmPlatforms
|
||||
import org.jetbrains.kotlin.platform.jvm.JvmPlatforms.unspecifiedJvmPlatform
|
||||
import org.jetbrains.kotlin.platform.konan.KonanPlatforms
|
||||
import org.jetbrains.kotlin.platform.konan.KonanPlatforms.defaultKonanPlatform
|
||||
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
object CommonPlatforms {
|
||||
|
||||
@Deprecated(
|
||||
message = "Should be accessed only by compatibility layer, other clients should use 'unspecifiedJvmPlatform'",
|
||||
level = DeprecationLevel.ERROR
|
||||
)
|
||||
object CompatCommonPlatform : TargetPlatform(
|
||||
setOf(
|
||||
unspecifiedJvmPlatform.single(),
|
||||
defaultJsPlatform.single(),
|
||||
defaultKonanPlatform.single()
|
||||
)
|
||||
), org.jetbrains.kotlin.analyzer.common.CommonPlatform
|
||||
|
||||
val defaultCommonPlatform: TargetPlatform
|
||||
get() = CompatCommonPlatform
|
||||
|
||||
val allSimplePlatforms: List<TargetPlatform>
|
||||
get() = sequence {
|
||||
yieldAll(JvmPlatforms.allJvmPlatforms)
|
||||
yieldAll(KonanPlatforms.allKonanPlatforms)
|
||||
yieldAll(JsPlatforms.allJsPlatforms)
|
||||
|
||||
// TODO(dsavvinov): extensions points?
|
||||
}.toList()
|
||||
}
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.platform.konan
|
||||
|
||||
import org.jetbrains.kotlin.platform.SimplePlatform
|
||||
import org.jetbrains.kotlin.platform.TargetPlatform
|
||||
import org.jetbrains.kotlin.platform.toTargetPlatform
|
||||
|
||||
abstract class KonanPlatform : SimplePlatform("Native") {
|
||||
override val oldFashionedDescription: String
|
||||
get() = "Kotlin/Native "
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
object KonanPlatforms {
|
||||
private object DefaultSimpleKonanPlatform : KonanPlatform()
|
||||
|
||||
@Deprecated(
|
||||
message = "Should be accessed only by compatibility layer, other clients should use 'defaultKonanPlatform'",
|
||||
level = DeprecationLevel.ERROR
|
||||
)
|
||||
object CompatKonanPlatform : TargetPlatform(setOf(DefaultSimpleKonanPlatform)),
|
||||
// Needed for backward compatibility, because old code uses INSTANCEOF checks instead of calling extensions
|
||||
org.jetbrains.kotlin.resolve.konan.platform.KonanPlatform {}
|
||||
|
||||
val defaultKonanPlatform: TargetPlatform
|
||||
get() = CompatKonanPlatform
|
||||
|
||||
val allKonanPlatforms: List<TargetPlatform> = listOf(defaultKonanPlatform)
|
||||
}
|
||||
|
||||
fun TargetPlatform?.isNative(): Boolean = this?.singleOrNull() is KonanPlatform
|
||||
@@ -1,27 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
@file:Suppress("DEPRECATION_ERROR")
|
||||
|
||||
package org.jetbrains.kotlin.resolve.konan.platform
|
||||
|
||||
import org.jetbrains.kotlin.platform.konan.KonanPlatforms
|
||||
import org.jetbrains.kotlin.resolve.TargetPlatform
|
||||
|
||||
@Deprecated(
|
||||
message = "This class is deprecated and will be removed soon, use API from 'org.jetbrains.kotlin.platform.*' packages instead",
|
||||
replaceWith = ReplaceWith("KonanPlatforms.defaultKonanPlatform", "org.jetbrains.kotlin.platform.konan.KonanPlatforms"),
|
||||
level = DeprecationLevel.ERROR
|
||||
)
|
||||
interface KonanPlatform : TargetPlatform {
|
||||
@JvmDefault
|
||||
override val platformName: String
|
||||
get() = "Native"
|
||||
|
||||
companion object {
|
||||
@JvmField
|
||||
val INSTANCE: KonanPlatform = KonanPlatforms.CompatKonanPlatform
|
||||
}
|
||||
}
|
||||
@@ -65,7 +65,6 @@ import org.jetbrains.kotlin.js.facade.TranslationUnit;
|
||||
import org.jetbrains.kotlin.js.facade.exceptions.TranslationException;
|
||||
import org.jetbrains.kotlin.js.sourceMap.SourceFilePathResolver;
|
||||
import org.jetbrains.kotlin.metadata.deserialization.BinaryVersion;
|
||||
import org.jetbrains.kotlin.name.FqName;
|
||||
import org.jetbrains.kotlin.progress.ProgressIndicatorAndCompilationCanceledStatus;
|
||||
import org.jetbrains.kotlin.psi.KtFile;
|
||||
import org.jetbrains.kotlin.serialization.js.ModuleKind;
|
||||
@@ -74,7 +73,6 @@ import org.jetbrains.kotlin.utils.*;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.jetbrains.kotlin.cli.common.ExitCode.COMPILATION_ERROR;
|
||||
import static org.jetbrains.kotlin.cli.common.ExitCode.OK;
|
||||
@@ -146,15 +144,6 @@ public class K2JSCompiler extends CLICompiler<K2JSCompilerArguments> {
|
||||
}
|
||||
Arrays.sort(allSources);
|
||||
|
||||
Set<FqName> dirtyPackages = nonCompiledSources.values().stream().map(KtFile::getPackageFqName).collect(Collectors.toSet());
|
||||
Map<FqName, byte[]> packageMetadata = new HashMap<>();
|
||||
for (Map.Entry<String, byte[]> e : incrementalDataProvider.getPackageMetadata().entrySet()) {
|
||||
FqName name = new FqName(e.getKey());
|
||||
if (!dirtyPackages.contains(name)) {
|
||||
packageMetadata.put(name, e.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
List<TranslationUnit> translationUnits = new ArrayList<>();
|
||||
for (i = 0; i < allSources.length; i++) {
|
||||
KtFile nonCompiled = nonCompiledSources.get(allSources[i]);
|
||||
@@ -166,7 +155,7 @@ public class K2JSCompiler extends CLICompiler<K2JSCompilerArguments> {
|
||||
translationUnits.add(new TranslationUnit.BinaryAst(translatedValue.getBinaryAst(), translatedValue.getInlineData()));
|
||||
}
|
||||
}
|
||||
return translator.translateUnits(reporter, translationUnits, mainCallParameters, jsAnalysisResult, packageMetadata);
|
||||
return translator.translateUnits(reporter, translationUnits, mainCallParameters, jsAnalysisResult);
|
||||
}
|
||||
|
||||
CollectionsKt.sortBy(allKotlinFiles, ktFile -> VfsUtilCore.virtualToIoFile(ktFile.getVirtualFile()));
|
||||
|
||||
@@ -28,12 +28,14 @@ import org.jetbrains.kotlin.incremental.components.ExpectActualTracker
|
||||
import org.jetbrains.kotlin.incremental.components.LookupTracker
|
||||
import org.jetbrains.kotlin.incremental.js.IncrementalDataProvider
|
||||
import org.jetbrains.kotlin.incremental.js.IncrementalResultsConsumer
|
||||
import org.jetbrains.kotlin.ir.backend.js.*
|
||||
import org.jetbrains.kotlin.ir.backend.js.KlibModuleRef
|
||||
import org.jetbrains.kotlin.ir.backend.js.compile
|
||||
import org.jetbrains.kotlin.ir.backend.js.generateKLib
|
||||
import org.jetbrains.kotlin.ir.backend.js.jsPhases
|
||||
import org.jetbrains.kotlin.js.config.EcmaVersion
|
||||
import org.jetbrains.kotlin.js.config.JSConfigurationKeys
|
||||
import org.jetbrains.kotlin.js.config.JsConfig
|
||||
import org.jetbrains.kotlin.js.config.SourceMapSourceEmbedding
|
||||
import org.jetbrains.kotlin.library.KotlinLibrary
|
||||
import org.jetbrains.kotlin.metadata.deserialization.BinaryVersion
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.serialization.js.ModuleKind
|
||||
@@ -42,6 +44,7 @@ import org.jetbrains.kotlin.utils.KotlinPaths
|
||||
import org.jetbrains.kotlin.utils.join
|
||||
import java.io.File
|
||||
import java.io.IOException
|
||||
import java.util.zip.ZipFile
|
||||
|
||||
enum class ProduceKind {
|
||||
DEFAULT, // Determine what to produce based on js-v1 options
|
||||
@@ -58,6 +61,68 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
|
||||
return K2JSCompilerArguments()
|
||||
}
|
||||
|
||||
private fun extractKlibFromZip(library: String, messageCollector: MessageCollector): File? {
|
||||
val zipLib = ZipFile(library)
|
||||
val tempDir = createTempDir(File(library).name, "klibjar")
|
||||
tempDir.deleteOnExit()
|
||||
var extractedKlibDir: File? = null
|
||||
for (entry in zipLib.entries()) {
|
||||
if (!entry.isDirectory) {
|
||||
zipLib.getInputStream(entry).use { input ->
|
||||
val outputEntryFile = File(tempDir, entry.name)
|
||||
outputEntryFile.parentFile.mkdirs()
|
||||
outputEntryFile.outputStream().use { output ->
|
||||
input.copyTo(output)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (entry.name.endsWith("KLIB/")) {
|
||||
extractedKlibDir = File(tempDir, entry.name)
|
||||
messageCollector.report(INFO, "Klib $library is extracted into $extractedKlibDir")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return extractedKlibDir
|
||||
}
|
||||
|
||||
private fun loadIrLibrary(library: String, messageCollector: MessageCollector): KlibModuleRef? {
|
||||
val libraryFile = File(library)
|
||||
var klibDir = when {
|
||||
FileUtil.isJarOrZip(libraryFile) -> {
|
||||
extractKlibFromZip(library, messageCollector) ?: return null
|
||||
}
|
||||
!libraryFile.isDirectory -> {
|
||||
messageCollector.report(ERROR, "Klib $library must be a directory")
|
||||
return null
|
||||
}
|
||||
else ->
|
||||
libraryFile
|
||||
}
|
||||
|
||||
var klibFiles = klibDir.listFiles()
|
||||
if (klibFiles.isEmpty()) {
|
||||
messageCollector.report(STRONG_WARNING, "Klib $library directory is empty")
|
||||
return null
|
||||
}
|
||||
|
||||
// Sometines gradle gives us a directory with klib directory inside
|
||||
val klibDirInsideDir = klibFiles.find { it.name.endsWith("KLIB") }
|
||||
if (klibDirInsideDir != null) {
|
||||
klibDir = klibDirInsideDir
|
||||
klibFiles = klibDir.listFiles()
|
||||
}
|
||||
|
||||
val metadataFile = klibFiles.find { it.extension == "klm" }
|
||||
|
||||
if (metadataFile == null) {
|
||||
messageCollector.report(STRONG_WARNING, "No metadata file (.klm) for klib: $klibDir")
|
||||
return null
|
||||
}
|
||||
|
||||
return KlibModuleRef(metadataFile.nameWithoutExtension, klibDir.absolutePath)
|
||||
}
|
||||
|
||||
override fun doExecute(
|
||||
arguments: K2JSCompilerArguments,
|
||||
configuration: CompilerConfiguration,
|
||||
@@ -79,7 +144,7 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
|
||||
arguments.pluginOptions,
|
||||
configuration
|
||||
)
|
||||
if (pluginLoadResult != OK) return pluginLoadResult
|
||||
if (pluginLoadResult != ExitCode.OK) return pluginLoadResult
|
||||
|
||||
val libraries: List<String> = configureLibraries(arguments.libraries)
|
||||
val friendLibraries: List<String> = configureLibraries(arguments.friendModules)
|
||||
@@ -139,11 +204,11 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
|
||||
val mainCallArguments = if (K2JsArgumentConstants.NO_CALL == arguments.main) null else emptyList<String>()
|
||||
|
||||
val loadedLibrariesNames = mutableSetOf<String>()
|
||||
val dependencies = mutableListOf<KotlinLibrary>()
|
||||
val friendDependencies = mutableListOf<KotlinLibrary>()
|
||||
val dependencies = mutableListOf<KlibModuleRef>()
|
||||
val friendDependencies = mutableListOf<KlibModuleRef>()
|
||||
|
||||
for (library in libraries) {
|
||||
val irLib = loadKlib(library)
|
||||
val irLib = loadIrLibrary(library, messageCollector) ?: continue
|
||||
if (irLib.moduleName !in loadedLibrariesNames) {
|
||||
dependencies.add(irLib)
|
||||
loadedLibrariesNames.add(irLib.moduleName)
|
||||
@@ -158,24 +223,6 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
|
||||
messageCollector.report(ERROR, "Unknown produce kind: ${arguments.irProduceOnly}. Valid values are: js, klib")
|
||||
}
|
||||
|
||||
if (produceKind == ProduceKind.KLIB || (produceKind == ProduceKind.DEFAULT && arguments.metaInfo)) {
|
||||
val outputKlibPath =
|
||||
if (arguments.irLegacyGradlePluginCompatimbility)
|
||||
File(outputFilePath).parent
|
||||
else
|
||||
"$outputFilePath.klib"
|
||||
|
||||
generateKLib(
|
||||
project = config.project,
|
||||
files = sourcesFiles,
|
||||
configuration = config.configuration,
|
||||
allDependencies = dependencies,
|
||||
friendDependencies = friendDependencies,
|
||||
outputKlibPath = outputKlibPath,
|
||||
nopack = arguments.irLegacyGradlePluginCompatimbility
|
||||
)
|
||||
}
|
||||
|
||||
if (produceKind == ProduceKind.JS || produceKind == ProduceKind.DEFAULT) {
|
||||
val phaseConfig = createPhaseConfig(jsPhases, arguments, messageCollector)
|
||||
|
||||
@@ -184,6 +231,7 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
|
||||
sourcesFiles,
|
||||
configuration,
|
||||
phaseConfig,
|
||||
immediateDependencies = dependencies,
|
||||
allDependencies = dependencies,
|
||||
friendDependencies = friendDependencies,
|
||||
mainArguments = mainCallArguments
|
||||
@@ -192,6 +240,19 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
|
||||
outputFile.writeText(compiledModule)
|
||||
}
|
||||
|
||||
if (produceKind == ProduceKind.KLIB || (produceKind == ProduceKind.DEFAULT && arguments.metaInfo)) {
|
||||
val outputKlibPath = "$outputFilePath.KLIB"
|
||||
generateKLib(
|
||||
project = config.project,
|
||||
files = sourcesFiles,
|
||||
configuration = config.configuration,
|
||||
immediateDependencies = dependencies,
|
||||
allDependencies = dependencies,
|
||||
friendDependencies = friendDependencies,
|
||||
outputKlibPath = outputKlibPath
|
||||
)
|
||||
}
|
||||
|
||||
return OK
|
||||
}
|
||||
|
||||
|
||||
@@ -122,7 +122,7 @@ class K2JSDce : CLITool<K2JSDceArguments>() {
|
||||
|
||||
private fun mapSourcePaths(inputFile: File, targetFile: File): Boolean {
|
||||
val json = try {
|
||||
parseJson(inputFile)
|
||||
InputStreamReader(FileInputStream(inputFile), "UTF-8").use { parseJson(it) }
|
||||
} catch (e: JsonSyntaxException) {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ private fun mergeStdlibParts(outputFile: File, wrapperFile: File, baseDir: File,
|
||||
|
||||
val sourceMapFile = File(file.parent, file.name + ".map")
|
||||
if (sourceMapFile.exists()) {
|
||||
val sourceMapParse = SourceMapParser.parse(sourceMapFile)
|
||||
val sourceMapParse = sourceMapFile.reader().use { SourceMapParser.parse(it) }
|
||||
when (sourceMapParse) {
|
||||
is SourceMapError -> {
|
||||
System.err.println("Error parsing source map file $sourceMapFile: ${sourceMapParse.message}")
|
||||
@@ -82,7 +82,7 @@ private fun mergeStdlibParts(outputFile: File, wrapperFile: File, baseDir: File,
|
||||
|
||||
outputFile.writeText(programText + "\n//# sourceMappingURL=${sourceMapFile.name}\n")
|
||||
|
||||
val sourceMapJson = parseJson(sourceMapContent)
|
||||
val sourceMapJson = StringReader(sourceMapContent).use { parseJson(it) }
|
||||
val sources = (sourceMapJson as JsonObject).properties["sources"] as JsonArray
|
||||
|
||||
sourceMapJson.properties["sourcesContent"] = JsonArray(*sources.elements.map { sourcePath ->
|
||||
|
||||
@@ -22,6 +22,7 @@ import org.jetbrains.kotlin.backend.jvm.jvmPhases
|
||||
import org.jetbrains.kotlin.cli.common.*
|
||||
import org.jetbrains.kotlin.cli.common.ExitCode.*
|
||||
import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments
|
||||
import org.jetbrains.kotlin.cli.common.config.addKotlinSourceRoot
|
||||
import org.jetbrains.kotlin.cli.common.extensions.ScriptEvaluationExtension
|
||||
import org.jetbrains.kotlin.cli.common.extensions.ShellExtension
|
||||
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity.*
|
||||
@@ -40,11 +41,12 @@ import org.jetbrains.kotlin.codegen.CompilationException
|
||||
import org.jetbrains.kotlin.config.*
|
||||
import org.jetbrains.kotlin.incremental.components.ExpectActualTracker
|
||||
import org.jetbrains.kotlin.incremental.components.LookupTracker
|
||||
import org.jetbrains.kotlin.javac.JavacWrapper
|
||||
import org.jetbrains.kotlin.load.java.JavaClassesTracker
|
||||
import org.jetbrains.kotlin.load.java.JvmAbi
|
||||
import org.jetbrains.kotlin.load.kotlin.incremental.components.IncrementalCompilationComponents
|
||||
import org.jetbrains.kotlin.metadata.deserialization.BinaryVersion
|
||||
import org.jetbrains.kotlin.metadata.jvm.deserialization.JvmMetadataVersion
|
||||
import org.jetbrains.kotlin.metadata.jvm.deserialization.JvmProtoBufUtil
|
||||
import org.jetbrains.kotlin.modules.JavaRootPath
|
||||
import org.jetbrains.kotlin.utils.KotlinPaths
|
||||
import org.jetbrains.kotlin.utils.PathUtil
|
||||
@@ -72,7 +74,7 @@ class K2JVMCompiler : CLICompiler<K2JVMCompilerArguments>() {
|
||||
val pluginLoadResult = loadPlugins(arguments, configuration)
|
||||
if (pluginLoadResult != ExitCode.OK) return pluginLoadResult
|
||||
|
||||
val moduleName = arguments.moduleName ?: JvmProtoBufUtil.DEFAULT_MODULE_NAME
|
||||
val moduleName = arguments.moduleName ?: JvmAbi.DEFAULT_MODULE_NAME
|
||||
configuration.put(CommonConfigurationKeys.MODULE_NAME, moduleName)
|
||||
|
||||
configuration.configureExplicitContentRoots(arguments)
|
||||
|
||||
@@ -39,7 +39,7 @@ class CliKotlinAsJavaSupport(
|
||||
return findFacadeFilesInPackage(packageFqName, scope)
|
||||
.groupBy { it.javaFileFacadeFqName }
|
||||
.mapNotNull { (facadeClassFqName, files) ->
|
||||
KtLightClassForFacade.createForFacade(psiManager, facadeClassFqName, scope)
|
||||
KtLightClassForFacade.createForFacade(psiManager, facadeClassFqName, scope, files)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,7 +56,12 @@ class CliKotlinAsJavaSupport(
|
||||
.orEmpty()
|
||||
|
||||
override fun getFacadeClasses(facadeFqName: FqName, scope: GlobalSearchScope): Collection<PsiClass> {
|
||||
return listOfNotNull(KtLightClassForFacade.createForFacade(psiManager, facadeFqName, scope))
|
||||
val filesForFacade = findFilesForFacade(facadeFqName, scope)
|
||||
if (filesForFacade.isEmpty()) return emptyList()
|
||||
|
||||
return listOfNotNull(
|
||||
KtLightClassForFacade.createForFacade(psiManager, facadeFqName, scope, filesForFacade)
|
||||
)
|
||||
}
|
||||
|
||||
override fun getScriptClasses(scriptFqName: FqName, scope: GlobalSearchScope): Collection<PsiClass> {
|
||||
|
||||
@@ -16,18 +16,13 @@
|
||||
|
||||
package org.jetbrains.kotlin.cli.jvm.compiler
|
||||
|
||||
import com.intellij.psi.PsiManager
|
||||
import com.intellij.psi.search.GlobalSearchScope
|
||||
import com.intellij.psi.util.CachedValue
|
||||
import org.jetbrains.kotlin.asJava.LightClassBuilder
|
||||
import org.jetbrains.kotlin.asJava.LightClassGenerationSupport
|
||||
import org.jetbrains.kotlin.asJava.builder.InvalidLightClassDataHolder
|
||||
import org.jetbrains.kotlin.asJava.builder.LightClassConstructionContext
|
||||
import org.jetbrains.kotlin.asJava.builder.LightClassDataHolder
|
||||
import org.jetbrains.kotlin.asJava.builder.LightClassDataHolderImpl
|
||||
import org.jetbrains.kotlin.asJava.classes.KtUltraLightClassForFacade
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
|
||||
@@ -44,14 +39,6 @@ import org.jetbrains.kotlin.resolve.BindingContext
|
||||
* To mitigate this, CliLightClassGenerationSupport hold a trace that is shared between the analyzer and JetLightClasses
|
||||
*/
|
||||
class CliLightClassGenerationSupport(private val traceHolder: CliTraceHolder) : LightClassGenerationSupport() {
|
||||
|
||||
override fun createUltraLightClassForFacade(
|
||||
manager: PsiManager,
|
||||
facadeClassFqName: FqName,
|
||||
lightClassDataCache: CachedValue<LightClassDataHolder.ForFacade>,
|
||||
files: Collection<KtFile>
|
||||
): KtUltraLightClassForFacade? = null
|
||||
|
||||
override fun createUltraLightClass(element: KtClassOrObject) = null
|
||||
|
||||
override fun createDataHolderForClass(classOrObject: KtClassOrObject, builder: LightClassBuilder): LightClassDataHolder.ForClass {
|
||||
|
||||
@@ -65,7 +65,6 @@ import com.intellij.util.lang.UrlClassLoader
|
||||
import org.jetbrains.annotations.TestOnly
|
||||
import org.jetbrains.kotlin.asJava.KotlinAsJavaSupport
|
||||
import org.jetbrains.kotlin.asJava.LightClassGenerationSupport
|
||||
import org.jetbrains.kotlin.asJava.classes.FacadeCache
|
||||
import org.jetbrains.kotlin.asJava.classes.KtLightClassForFacade
|
||||
import org.jetbrains.kotlin.asJava.finder.JavaElementFinder
|
||||
import org.jetbrains.kotlin.backend.common.extensions.IrGenerationExtension
|
||||
@@ -680,7 +679,7 @@ class KotlinCoreEnvironment private constructor(
|
||||
fun registerProjectServices(project: MockProject) {
|
||||
with(project) {
|
||||
registerService(KotlinJavaPsiFacade::class.java, KotlinJavaPsiFacade(this))
|
||||
registerService(FacadeCache::class.java, FacadeCache(this))
|
||||
registerService(KtLightClassForFacade.FacadeStubCache::class.java, KtLightClassForFacade.FacadeStubCache(this))
|
||||
registerService(ModuleAnnotationsResolver::class.java, CliModuleAnnotationsResolver())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,13 +66,11 @@ import org.jetbrains.kotlin.modules.Module
|
||||
import org.jetbrains.kotlin.modules.TargetId
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.platform.TargetPlatform
|
||||
import org.jetbrains.kotlin.platform.jvm.JvmPlatforms
|
||||
import org.jetbrains.kotlin.progress.ProgressIndicatorAndCompilationCanceledStatus
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.resolve.PlatformDependentAnalyzerServices
|
||||
import org.jetbrains.kotlin.resolve.TargetPlatform
|
||||
import org.jetbrains.kotlin.resolve.jvm.KotlinJavaPsiFacade
|
||||
import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatformAnalyzerServices
|
||||
import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatform
|
||||
import org.jetbrains.kotlin.utils.newLinkedHashMapWithExpectedSize
|
||||
import org.jetbrains.kotlin.utils.tryConstructClassFromStringArgs
|
||||
import java.io.File
|
||||
@@ -303,11 +301,7 @@ object KotlinToJVMBytecodeCompiler {
|
||||
|
||||
val dependencies: MutableList<ModuleInfo> = mutableListOf()
|
||||
|
||||
override val platform: TargetPlatform
|
||||
get() = JvmPlatforms.unspecifiedJvmPlatform
|
||||
|
||||
override val analyzerServices: PlatformDependentAnalyzerServices
|
||||
get() = JvmPlatformAnalyzerServices
|
||||
override val platform: TargetPlatform? get() = JvmPlatform
|
||||
|
||||
override fun dependencies(): List<ModuleInfo> {
|
||||
return dependencies
|
||||
|
||||
@@ -37,7 +37,7 @@ import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.PackageFragmentProvider
|
||||
import org.jetbrains.kotlin.descriptors.impl.CompositePackageFragmentProvider
|
||||
import org.jetbrains.kotlin.frontend.java.di.createContainerForLazyResolveWithJava
|
||||
import org.jetbrains.kotlin.frontend.java.di.createContainerForTopDownAnalyzerForJvm
|
||||
import org.jetbrains.kotlin.frontend.java.di.initJvmBuiltInsForTopDownAnalysis
|
||||
import org.jetbrains.kotlin.frontend.java.di.initialize
|
||||
import org.jetbrains.kotlin.incremental.components.ExpectActualTracker
|
||||
@@ -55,7 +55,6 @@ import org.jetbrains.kotlin.load.kotlin.incremental.IncrementalPackageFragmentPr
|
||||
import org.jetbrains.kotlin.load.kotlin.incremental.IncrementalPackagePartProvider
|
||||
import org.jetbrains.kotlin.modules.TargetId
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.platform.jvm.JvmPlatforms
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.resolve.*
|
||||
import org.jetbrains.kotlin.resolve.jvm.JavaDescriptorResolver
|
||||
@@ -167,13 +166,10 @@ object TopDownAnalyzerFacadeForJVM {
|
||||
// Scope for the dependency module contains everything except files present in the scope for the source module
|
||||
val dependencyScope = GlobalSearchScope.notScope(sourceScope)
|
||||
|
||||
val dependenciesContainer = createContainerForLazyResolveWithJava(
|
||||
JvmPlatforms.jvmPlatformByTargetVersion(jvmTarget),
|
||||
dependenciesContext, trace, DeclarationProviderFactory.EMPTY, dependencyScope, moduleClassResolver,
|
||||
targetEnvironment, lookupTracker, expectActualTracker,
|
||||
packagePartProvider(dependencyScope), languageVersionSettings,
|
||||
useBuiltInsProvider = true,
|
||||
configureJavaClassFinder = configureJavaClassFinder
|
||||
val dependenciesContainer = createContainerForTopDownAnalyzerForJvm(
|
||||
dependenciesContext, trace, DeclarationProviderFactory.EMPTY, dependencyScope, lookupTracker, expectActualTracker,
|
||||
packagePartProvider(dependencyScope), moduleClassResolver, targetEnvironment, jvmTarget, languageVersionSettings,
|
||||
configureJavaClassFinder
|
||||
)
|
||||
|
||||
moduleClassResolver.compiledCodeResolver = dependenciesContainer.get()
|
||||
@@ -199,14 +195,10 @@ object TopDownAnalyzerFacadeForJVM {
|
||||
// CliLightClassGenerationSupport#initialize is invoked when container is created, so only the last module descriptor is going
|
||||
// to be stored in CliLightClassGenerationSupport, and it better be the source one (otherwise light classes would not be found)
|
||||
// TODO: get rid of duplicate invocation of CodeAnalyzerInitializer#initialize, or refactor CliLightClassGenerationSupport
|
||||
val container = createContainerForLazyResolveWithJava(
|
||||
JvmPlatforms.jvmPlatformByTargetVersion(jvmTarget),
|
||||
moduleContext, trace, declarationProviderFactory(storageManager, files), sourceScope, moduleClassResolver,
|
||||
targetEnvironment, lookupTracker, expectActualTracker,
|
||||
partProvider, languageVersionSettings,
|
||||
useBuiltInsProvider = true,
|
||||
configureJavaClassFinder = configureJavaClassFinder,
|
||||
javaClassTracker = configuration[JVMConfigurationKeys.JAVA_CLASSES_TRACKER]
|
||||
val container = createContainerForTopDownAnalyzerForJvm(
|
||||
moduleContext, trace, declarationProviderFactory(storageManager, files), sourceScope, lookupTracker, expectActualTracker,
|
||||
partProvider, moduleClassResolver, targetEnvironment, jvmTarget, languageVersionSettings, configureJavaClassFinder,
|
||||
configuration[JVMConfigurationKeys.JAVA_CLASSES_TRACKER]
|
||||
).apply {
|
||||
initJvmBuiltInsForTopDownAnalysis()
|
||||
(partProvider as? IncrementalPackagePartProvider)?.deserializationConfiguration = get()
|
||||
@@ -276,7 +268,7 @@ object TopDownAnalyzerFacadeForJVM {
|
||||
}
|
||||
|
||||
private fun createModuleContext(project: Project, configuration: CompilerConfiguration): MutableModuleContext {
|
||||
val projectContext = ProjectContext(project, "TopDownAnalyzer for JVM")
|
||||
val projectContext = ProjectContext(project)
|
||||
val builtIns = JvmBuiltIns(projectContext.storageManager, JvmBuiltIns.Kind.FROM_DEPENDENCIES)
|
||||
return ContextForNewModule(
|
||||
projectContext, Name.special("<${configuration.getNotNull(CommonConfigurationKeys.MODULE_NAME)}>"), builtIns, null
|
||||
|
||||
@@ -31,9 +31,9 @@ import org.jetbrains.kotlin.codegen.CompilationException
|
||||
import org.jetbrains.kotlin.config.CommonConfigurationKeys
|
||||
import org.jetbrains.kotlin.config.CompilerConfiguration
|
||||
import org.jetbrains.kotlin.config.Services
|
||||
import org.jetbrains.kotlin.load.java.JvmAbi
|
||||
import org.jetbrains.kotlin.metadata.builtins.BuiltInsBinaryVersion
|
||||
import org.jetbrains.kotlin.metadata.deserialization.BinaryVersion
|
||||
import org.jetbrains.kotlin.metadata.jvm.deserialization.JvmProtoBufUtil
|
||||
import org.jetbrains.kotlin.utils.KotlinPaths
|
||||
import java.io.File
|
||||
|
||||
@@ -67,7 +67,7 @@ class K2MetadataCompiler : CLICompiler<K2MetadataCompilerArguments>() {
|
||||
configuration.addJvmClasspathRoots(arguments.classpath!!.split(File.pathSeparatorChar).map(::File))
|
||||
}
|
||||
|
||||
configuration.put(CommonConfigurationKeys.MODULE_NAME, arguments.moduleName ?: JvmProtoBufUtil.DEFAULT_MODULE_NAME)
|
||||
configuration.put(CommonConfigurationKeys.MODULE_NAME, arguments.moduleName ?: JvmAbi.DEFAULT_MODULE_NAME)
|
||||
|
||||
configuration.put(CLIConfigurationKeys.ALLOW_KOTLIN_PACKAGE, arguments.allowKotlinPackage)
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.cli.metadata
|
||||
|
||||
import org.jetbrains.kotlin.analyzer.common.CommonResolverForModuleFactory
|
||||
import org.jetbrains.kotlin.analyzer.common.CommonAnalyzerFacade
|
||||
import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys
|
||||
import org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport
|
||||
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity
|
||||
@@ -68,7 +68,7 @@ open class MetadataSerializer(
|
||||
|
||||
val analyzer = AnalyzerWithCompilerReport(messageCollector, configuration.languageVersionSettings)
|
||||
analyzer.analyzeAndReport(files) {
|
||||
CommonResolverForModuleFactory.analyzeFiles(files, moduleName, dependOnOldBuiltIns, configuration.languageVersionSettings) { content ->
|
||||
CommonAnalyzerFacade.analyzeFiles(files, moduleName, dependOnOldBuiltIns, configuration.languageVersionSettings) { content ->
|
||||
environment.createPackagePartProvider(content.moduleContentScope)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -255,5 +255,3 @@ messages/**)
|
||||
|
||||
# used in LazyScriptDescriptor
|
||||
-keep class org.jetbrains.kotlin.utils.addToStdlib.AddToStdlibKt { *; }
|
||||
|
||||
-keep class com.intellij.openapi.vfs.impl.jar.CoreJarFileSystem { *; }
|
||||
@@ -254,5 +254,3 @@ messages/**)
|
||||
|
||||
# used in LazyScriptDescriptor
|
||||
-keep class org.jetbrains.kotlin.utils.addToStdlib.AddToStdlibKt { *; }
|
||||
|
||||
-keep class com.intellij.openapi.vfs.impl.jar.CoreJarFileSystem { *; }
|
||||
@@ -1,260 +0,0 @@
|
||||
-injars '<kotlin-compiler-jar-before-shrink>'(
|
||||
!org/apache/log4j/jmx/Agent*,
|
||||
!org/apache/log4j/net/JMS*,
|
||||
!org/apache/log4j/net/SMTP*,
|
||||
!org/apache/log4j/or/jms/MessageRenderer*,
|
||||
!org/jdom/xpath/Jaxen*,
|
||||
!org/jline/builtins/ssh/**,
|
||||
!org/mozilla/javascript/xml/impl/xmlbeans/**,
|
||||
!net/sf/cglib/**,
|
||||
!META-INF/maven**,
|
||||
**.class,**.properties,**.kt,**.kotlin_*,**.jnilib,**.so,**.dll,**.txt,**.caps,
|
||||
META-INF/services/**,META-INF/native/**,META-INF/extensions/**,META-INF/MANIFEST.MF,
|
||||
messages/**)
|
||||
|
||||
-outjars '<kotlin-compiler-jar>'
|
||||
|
||||
-dontnote **
|
||||
-dontwarn com.intellij.util.ui.IsRetina*
|
||||
-dontwarn com.intellij.util.ui.UIUtilities
|
||||
-dontwarn com.intellij.util.RetinaImage*
|
||||
-dontwarn apple.awt.*
|
||||
-dontwarn dk.brics.automaton.*
|
||||
-dontwarn org.fusesource.**
|
||||
-dontwarn org.imgscalr.Scalr**
|
||||
-dontwarn org.xerial.snappy.SnappyBundleActivator
|
||||
-dontwarn com.intellij.util.CompressionUtil
|
||||
-dontwarn com.intellij.util.SnappyInitializer
|
||||
-dontwarn com.intellij.util.SVGLoader
|
||||
-dontwarn com.intellij.util.SVGLoader$MyTranscoder
|
||||
-dontwarn com.intellij.util.ImageLoader$ImageDesc
|
||||
-dontwarn net.sf.cglib.**
|
||||
-dontwarn org.objectweb.asm.** # this is ASM3, the old version that we do not use
|
||||
-dontwarn com.sun.jna.NativeString
|
||||
-dontwarn com.sun.jna.WString
|
||||
-dontwarn com.intellij.psi.util.PsiClassUtil
|
||||
-dontwarn org.apache.hadoop.io.compress.*
|
||||
-dontwarn com.google.j2objc.annotations.Weak
|
||||
-dontwarn org.iq80.snappy.HadoopSnappyCodec$SnappyCompressionInputStream
|
||||
-dontwarn org.iq80.snappy.HadoopSnappyCodec$SnappyCompressionOutputStream
|
||||
-dontwarn com.google.common.util.concurrent.*
|
||||
-dontwarn org.apache.xerces.dom.**
|
||||
-dontwarn org.apache.xerces.util.**
|
||||
-dontwarn org.w3c.dom.ElementTraversal
|
||||
-dontwarn javaslang.match.annotation.Unapply
|
||||
-dontwarn javaslang.match.annotation.Patterns
|
||||
-dontwarn javaslang.*
|
||||
-dontwarn com.google.errorprone.**
|
||||
-dontwarn com.google.j2objc.**
|
||||
-dontwarn javax.crypto.**
|
||||
-dontwarn java.lang.invoke.MethodHandle
|
||||
-dontwarn org.jline.builtins.Nano$Buffer
|
||||
-dontwarn org.jetbrains.annotations.ReadOnly
|
||||
-dontwarn org.jetbrains.annotations.Mutable
|
||||
-dontwarn com.intellij.util.io.TarUtil
|
||||
-dontwarn com.intellij.util.io.Compressor$Tar
|
||||
|
||||
# Annotations from intellijCore/annotations.jar that not presented in org.jetbrains.annotations
|
||||
-dontwarn org.jetbrains.annotations.Async*
|
||||
-dontwarn org.jetbrains.annotations.Nls$Capitalization
|
||||
|
||||
# Nullability annotations used in Guava
|
||||
-dontwarn org.checkerframework.checker.nullness.compatqual.NullableDecl
|
||||
-dontwarn org.checkerframework.checker.nullness.compatqual.MonotonicNonNullDecl
|
||||
-dontwarn org.checkerframework.checker.nullness.qual.Nullable
|
||||
-dontwarn org.checkerframework.checker.nullness.qual.MonotonicNonNull
|
||||
|
||||
# Depends on apache batick which has lots of dependencies
|
||||
-dontwarn com.intellij.util.SVGLoader*
|
||||
-dontwarn org.apache.batik.script.rhino.RhinoInterpreter
|
||||
-dontwarn org.apache.batik.script.rhino.RhinoInterpreterFactory
|
||||
|
||||
# The appropriate jar is either loaded separately or added explicitly to the classpath then needed
|
||||
-dontwarn org.jetbrains.kotlin.scripting.compiler.plugin.ScriptingCompilerConfigurationComponentRegistrar
|
||||
|
||||
-dontwarn org.jdom.xpath.jaxen.*
|
||||
-dontwarn com.intellij.util.io.Decompressor*
|
||||
-dontwarn org.w3c.dom.Location
|
||||
-dontwarn org.w3c.dom.Window
|
||||
-dontwarn org.slf4j.**
|
||||
|
||||
|
||||
#-libraryjars '<rtjar>'
|
||||
#-libraryjars '<jssejar>'
|
||||
#-libraryjars '<bootstrap.runtime>'
|
||||
#-libraryjars '<bootstrap.reflect>'
|
||||
#-libraryjars '<bootstrap.script.runtime>'
|
||||
#-libraryjars '<tools.jar>'
|
||||
|
||||
-dontoptimize
|
||||
-dontobfuscate
|
||||
|
||||
-keep class org.fusesource.** { *; }
|
||||
-keep class com.sun.jna.** { *; }
|
||||
|
||||
-keep class org.jetbrains.annotations.** {
|
||||
public protected *;
|
||||
}
|
||||
|
||||
-keep class javax.inject.** {
|
||||
public protected *;
|
||||
}
|
||||
|
||||
-keep class org.jetbrains.kotlin.** {
|
||||
public protected *;
|
||||
}
|
||||
|
||||
-keep class org.jetbrains.kotlin.compiler.plugin.** {
|
||||
public protected *;
|
||||
}
|
||||
|
||||
-keep class org.jetbrains.kotlin.extensions.** {
|
||||
public protected *;
|
||||
}
|
||||
|
||||
-keep class org.jetbrains.kotlin.protobuf.** {
|
||||
public protected *;
|
||||
}
|
||||
|
||||
-keep class org.jetbrains.kotlin.container.** { *; }
|
||||
|
||||
-keep class org.jetbrains.org.objectweb.asm.Opcodes { *; }
|
||||
|
||||
-keep class org.jetbrains.kotlin.codegen.extensions.** {
|
||||
public protected *;
|
||||
}
|
||||
|
||||
-keepclassmembers class com.intellij.openapi.vfs.VirtualFile {
|
||||
public protected *;
|
||||
}
|
||||
|
||||
-keep class com.intellij.openapi.vfs.StandardFileSystems {
|
||||
public static *;
|
||||
}
|
||||
|
||||
# needed for jar cache cleanup in the gradle plugin and compile daemon
|
||||
-keepclassmembers class com.intellij.openapi.vfs.impl.ZipHandler {
|
||||
public static void clearFileAccessorCache();
|
||||
}
|
||||
|
||||
-keep class jet.** {
|
||||
public protected *;
|
||||
}
|
||||
|
||||
-keep class com.intellij.psi.** {
|
||||
public protected *;
|
||||
}
|
||||
|
||||
# This is needed so that the platform code which parses XML wouldn't fail, see KT-16968
|
||||
# This API is used from org.jdom.input.SAXBuilder via reflection.
|
||||
-keep class org.jdom.input.JAXPParserFactory { public ** createParser(...); }
|
||||
# Without this class PluginManagerCore.loadDescriptorFromJar fails
|
||||
-keep class org.jdom.output.XMLOutputter { *; }
|
||||
|
||||
# for kdoc & dokka
|
||||
-keep class com.intellij.openapi.util.TextRange { *; }
|
||||
-keep class com.intellij.lang.impl.PsiBuilderImpl* {
|
||||
public protected *;
|
||||
}
|
||||
-keep class com.intellij.openapi.util.text.StringHash { *; }
|
||||
|
||||
# for j2k
|
||||
-keep class com.intellij.codeInsight.NullableNotNullManager { public protected *; }
|
||||
|
||||
# for gradle (see KT-12549)
|
||||
-keep class com.intellij.lang.properties.charset.Native2AsciiCharsetProvider { *; }
|
||||
|
||||
# for kotlin-build-common (consider repacking compiler together with kotlin-build-common and remove this part afterwards)
|
||||
-keep class com.intellij.util.io.IOUtil { public *; }
|
||||
-keep class com.intellij.openapi.util.io.FileUtil { public *; }
|
||||
-keep class com.intellij.util.SystemProperties { public *; }
|
||||
-keep class com.intellij.util.containers.hash.LinkedHashMap { *; }
|
||||
-keep class com.intellij.util.containers.ConcurrentIntObjectMap { *; }
|
||||
-keep class com.intellij.util.containers.ComparatorUtil { *; }
|
||||
-keep class com.intellij.util.io.PersistentHashMapValueStorage { *; }
|
||||
-keep class com.intellij.util.io.PersistentHashMap { *; }
|
||||
-keep class com.intellij.util.io.BooleanDataDescriptor { *; }
|
||||
-keep class com.intellij.util.io.EnumeratorStringDescriptor { *; }
|
||||
-keep class com.intellij.util.io.ExternalIntegerKeyDescriptor { *; }
|
||||
-keep class com.intellij.util.containers.hash.EqualityPolicy { *; }
|
||||
-keep class com.intellij.util.containers.hash.EqualityPolicy.* { *; }
|
||||
-keep class com.intellij.util.containers.Interner { *; }
|
||||
-keep class gnu.trove.TIntHashSet { *; }
|
||||
-keep class gnu.trove.TIntIterator { *; }
|
||||
-keep class org.iq80.snappy.SlowMemory { *; }
|
||||
-keep class javaslang.match.PatternsProcessor { *; }
|
||||
|
||||
-keepclassmembers enum * {
|
||||
public static **[] values();
|
||||
public static ** valueOf(java.lang.String);
|
||||
}
|
||||
|
||||
-keepclassmembers class * {
|
||||
** toString();
|
||||
** hashCode();
|
||||
void start();
|
||||
void stop();
|
||||
void dispose();
|
||||
}
|
||||
|
||||
-keep class org.jetbrains.org.objectweb.asm.tree.AnnotationNode { *; }
|
||||
-keep class org.jetbrains.org.objectweb.asm.tree.ClassNode { *; }
|
||||
-keep class org.jetbrains.org.objectweb.asm.tree.LocalVariableNode { *; }
|
||||
-keep class org.jetbrains.org.objectweb.asm.tree.MethodNode { *; }
|
||||
-keep class org.jetbrains.org.objectweb.asm.tree.FieldNode { *; }
|
||||
-keep class org.jetbrains.org.objectweb.asm.tree.ParameterNode { *; }
|
||||
-keep class org.jetbrains.org.objectweb.asm.tree.TypeAnnotationNode { *; }
|
||||
-keep class org.jetbrains.org.objectweb.asm.tree.InsnList { *; }
|
||||
|
||||
-keep class org.jetbrains.org.objectweb.asm.signature.SignatureReader { *; }
|
||||
-keep class org.jetbrains.org.objectweb.asm.signature.SignatureVisitor { *; }
|
||||
|
||||
-keep class org.jetbrains.org.objectweb.asm.Type {
|
||||
public protected *;
|
||||
}
|
||||
|
||||
-keepclassmembers class org.jetbrains.org.objectweb.asm.ClassReader {
|
||||
*** SKIP_CODE;
|
||||
*** SKIP_DEBUG;
|
||||
*** SKIP_FRAMES;
|
||||
}
|
||||
|
||||
-keepclassmembers class com.intellij.openapi.project.Project {
|
||||
** getBasePath();
|
||||
}
|
||||
|
||||
# for kotlin-android-extensions in maven
|
||||
-keep class com.intellij.openapi.module.ModuleServiceManager { public *; }
|
||||
|
||||
# for building kotlin-build-common-test
|
||||
-keep class org.jetbrains.kotlin.build.SerializationUtilsKt { *; }
|
||||
|
||||
# for tools.jar
|
||||
-keep class com.sun.tools.javac.** { *; }
|
||||
-keep class com.sun.source.** { *; }
|
||||
|
||||
# for coroutines
|
||||
-keep class kotlinx.coroutines.** { *; }
|
||||
|
||||
# for webdemo
|
||||
-keep class com.intellij.openapi.progress.ProgressManager { *; }
|
||||
|
||||
# for kapt
|
||||
-keep class com.intellij.openapi.project.Project { *; }
|
||||
-keepclassmembers class com.intellij.util.PathUtil {
|
||||
public static java.lang.String getJarPathForClass(java.lang.Class);
|
||||
}
|
||||
|
||||
-keepclassmembers class com.intellij.util.PathUtil {
|
||||
public static java.lang.String getJarPathForClass(java.lang.Class);
|
||||
}
|
||||
|
||||
# remove when KT-18563 would be fixed
|
||||
-keep class org.jetbrains.kotlin.psi.psiUtil.PsiUtilsKt { *; }
|
||||
|
||||
-keep class net.jpountz.lz4.* { *; }
|
||||
|
||||
# used in LazyScriptDescriptor
|
||||
-keep class org.jetbrains.kotlin.utils.addToStdlib.AddToStdlibKt { *; }
|
||||
|
||||
-keep class com.intellij.openapi.vfs.impl.jar.CoreJarFileSystem { *; }
|
||||
@@ -254,5 +254,3 @@ messages/**)
|
||||
|
||||
# used in LazyScriptDescriptor
|
||||
-keep class org.jetbrains.kotlin.utils.addToStdlib.AddToStdlibKt { *; }
|
||||
|
||||
-keep class com.intellij.openapi.vfs.impl.jar.CoreJarFileSystem { *; }
|
||||
@@ -102,11 +102,6 @@ class StorageComponentContainer(
|
||||
return this
|
||||
}
|
||||
|
||||
internal fun registerClashResolvers(resolvers: List<PlatformExtensionsClashResolver<*>>): StorageComponentContainer {
|
||||
componentStorage.registerClashResolvers(resolvers)
|
||||
return this
|
||||
}
|
||||
|
||||
override fun <T> create(request: Class<T>): T {
|
||||
val constructorBinding = request.bindToConstructor(unknownContext)
|
||||
val args = constructorBinding.argumentDescriptors.map { it.getValue() }.toTypedArray()
|
||||
|
||||
@@ -46,14 +46,6 @@ fun StorageComponentContainer.useInstance(instance: Any) {
|
||||
registerInstance(instance)
|
||||
}
|
||||
|
||||
fun StorageComponentContainer.useInstanceIfNotNull(instance: Any?) {
|
||||
if (instance != null) registerInstance(instance)
|
||||
}
|
||||
|
||||
fun StorageComponentContainer.useClashResolver(clashResolver: PlatformExtensionsClashResolver<*>) {
|
||||
registerClashResolvers(listOf(clashResolver))
|
||||
}
|
||||
|
||||
inline operator fun <reified T : Any> ComponentProvider.getValue(thisRef: Any?, desc: KProperty<*>): T {
|
||||
return getService(T::class.java)
|
||||
}
|
||||
|
||||
@@ -70,20 +70,4 @@ internal class ComponentRegistry {
|
||||
}
|
||||
registrationMap += other.registrationMap
|
||||
}
|
||||
|
||||
fun resolveClashesIfAny(container: ComponentContainer, clashResolvers: List<PlatformExtensionsClashResolver<*>>) {
|
||||
/*
|
||||
The idea is to create descriptor, which is very similar to other SingletonDescriptor, but instead of calling
|
||||
constructor we call 'resolveExtensionsClash' with values of clashed components as arguments.
|
||||
|
||||
By mimicking the usual descriptors we get lazy evaluation and consistency checks for free.
|
||||
*/
|
||||
for (resolver in clashResolvers) {
|
||||
val clashedComponents = registrationMap[resolver.applicableTo] as? Collection<ComponentDescriptor> ?: continue
|
||||
if (clashedComponents.size <= 1) continue
|
||||
|
||||
val substituteDescriptor = ClashResolutionDescriptor(container, resolver, clashedComponents.toList())
|
||||
registrationMap[resolver.applicableTo] = substituteDescriptor
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,6 @@
|
||||
package org.jetbrains.kotlin.container
|
||||
|
||||
import java.io.Closeable
|
||||
import java.lang.IllegalStateException
|
||||
import java.lang.reflect.Type
|
||||
import java.util.*
|
||||
|
||||
@@ -145,29 +144,6 @@ open class SingletonTypeComponentDescriptor(container: ComponentContainer, val k
|
||||
override fun toString(): String = "Singleton: ${klass.simpleName}"
|
||||
}
|
||||
|
||||
internal class ClashResolutionDescriptor<E : PlatformSpecificExtension<E>>(
|
||||
container: ComponentContainer,
|
||||
private val resolver: PlatformExtensionsClashResolver<E>,
|
||||
private val clashedComponents: List<ComponentDescriptor>
|
||||
) : SingletonDescriptor(container) {
|
||||
|
||||
override fun createInstance(context: ValueResolveContext): Any {
|
||||
state = ComponentState.Initializing
|
||||
val extensions = computeArguments(clashedComponents) as List<E>
|
||||
val resolution = resolver.resolveExtensionsClash(extensions)
|
||||
state = ComponentState.Initialized
|
||||
return resolution
|
||||
}
|
||||
|
||||
override fun getRegistrations(): Iterable<Type> {
|
||||
throw IllegalStateException("Shouldn't be called")
|
||||
}
|
||||
|
||||
override fun getDependencies(context: ValueResolveContext): Collection<Type> {
|
||||
throw IllegalStateException("Shouldn't be called")
|
||||
}
|
||||
}
|
||||
|
||||
class ImplicitSingletonTypeComponentDescriptor(container: ComponentContainer, klass: Class<*>) : SingletonTypeComponentDescriptor(container, klass) {
|
||||
override fun toString(): String {
|
||||
return "Implicit: ${klass.simpleName}"
|
||||
|
||||
@@ -19,7 +19,6 @@ package org.jetbrains.kotlin.container
|
||||
import com.intellij.util.containers.MultiMap
|
||||
import java.io.Closeable
|
||||
import java.io.PrintStream
|
||||
import java.lang.IllegalStateException
|
||||
import java.lang.reflect.Modifier
|
||||
import java.lang.reflect.ParameterizedType
|
||||
import java.lang.reflect.Type
|
||||
@@ -34,28 +33,19 @@ enum class ComponentStorageState {
|
||||
Disposed
|
||||
}
|
||||
|
||||
internal class InvalidCardinalityException(message: String) : Exception(message)
|
||||
internal class InvalidCardinalityException(message: String, val descriptors: Collection<ComponentDescriptor>) : Exception(message)
|
||||
|
||||
class ComponentStorage(private val myId: String, parent: ComponentStorage?) : ValueResolver {
|
||||
var state = ComponentStorageState.Initial
|
||||
private val registry = ComponentRegistry()
|
||||
init {
|
||||
parent?.let { registry.addAll(it.registry) }
|
||||
}
|
||||
|
||||
private val descriptors = LinkedHashSet<ComponentDescriptor>()
|
||||
private val dependencies = MultiMap.createLinkedSet<ComponentDescriptor, Type>()
|
||||
private val clashResolvers = ArrayList<PlatformExtensionsClashResolver<*>>()
|
||||
private val registry = ComponentRegistry()
|
||||
|
||||
init {
|
||||
parent?.let {
|
||||
registry.addAll(it.registry)
|
||||
clashResolvers.addAll(it.clashResolvers)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override fun resolve(request: Type, context: ValueResolveContext): ValueDescriptor? {
|
||||
fun ComponentDescriptor.isDefaultComponent(): Boolean =
|
||||
this is DefaultInstanceComponentDescriptor || this is DefaultSingletonTypeComponentDescriptor
|
||||
|
||||
if (state == ComponentStorageState.Initial)
|
||||
throw ContainerConsistencyException("Container was not composed before resolving")
|
||||
|
||||
@@ -63,16 +53,9 @@ class ComponentStorage(private val myId: String, parent: ComponentStorage?) : Va
|
||||
if (entry.isNotEmpty()) {
|
||||
registerDependency(request, context)
|
||||
|
||||
if (entry.size == 1) return entry.single()
|
||||
|
||||
val nonDefault = entry.filterNot { it.isDefaultComponent() }
|
||||
if (nonDefault.isEmpty()) return entry.first()
|
||||
|
||||
return nonDefault.singleOrNull()
|
||||
?: throw InvalidCardinalityException(
|
||||
"Request $request cannot be satisfied because there is more than one type registered\n" +
|
||||
"Clashed registrations: ${entry.joinToString()}"
|
||||
)
|
||||
if (entry.size > 1)
|
||||
throw InvalidCardinalityException("Request $request cannot be satisfied because there is more than one type registered", entry)
|
||||
return entry.singleOrNull()
|
||||
}
|
||||
return null
|
||||
}
|
||||
@@ -114,10 +97,6 @@ class ComponentStorage(private val myId: String, parent: ComponentStorage?) : Va
|
||||
return registry.tryGetEntry(request)
|
||||
}
|
||||
|
||||
internal fun registerClashResolvers(resolvers: List<PlatformExtensionsClashResolver<*>>) {
|
||||
clashResolvers.addAll(resolvers)
|
||||
}
|
||||
|
||||
internal fun registerDescriptors(context: ComponentResolveContext, items: List<ComponentDescriptor>) {
|
||||
if (state == ComponentStorageState.Disposed) {
|
||||
throw ContainerConsistencyException("Cannot register descriptors in $state state")
|
||||
@@ -146,7 +125,6 @@ class ComponentStorage(private val myId: String, parent: ComponentStorage?) : Va
|
||||
|
||||
val implicits = inspectDependenciesAndRegisterAdhoc(context, descriptors)
|
||||
|
||||
registry.resolveClashesIfAny(context.container, clashResolvers)
|
||||
injectProperties(context, descriptors + implicits)
|
||||
}
|
||||
|
||||
|
||||
@@ -134,10 +134,6 @@ open class CompilerCallbackServicesFacadeServer(
|
||||
incrementalResultsConsumer!!.processInlineFunctions(functions)
|
||||
}
|
||||
|
||||
override fun incrementalResultsConsumer_processPackageMetadata(packageName: String, metadata: ByteArray) {
|
||||
incrementalResultsConsumer!!.processPackageMetadata(packageName, metadata)
|
||||
}
|
||||
|
||||
override fun incrementalDataProvider_getHeaderMetadata(): ByteArray = incrementalDataProvider!!.headerMetadata
|
||||
|
||||
override fun incrementalDataProvider_getMetadataVersion(): IntArray = incrementalDataProvider!!.metadataVersion
|
||||
@@ -146,9 +142,4 @@ open class CompilerCallbackServicesFacadeServer(
|
||||
incrementalDataProvider!!.compiledPackageParts.entries.map {
|
||||
CompiledPackagePart(it.key.path, it.value.metadata, it.value.binaryAst, it.value.inlineData)
|
||||
}
|
||||
|
||||
override fun incrementalDataProvider_getPackageMetadata(): Collection<PackageMetadata> =
|
||||
incrementalDataProvider!!.packageMetadata.entries.map { (fqName, metadata) ->
|
||||
PackageMetadata(fqName, metadata)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,9 +112,6 @@ interface CompilerCallbackServicesFacade : Remote {
|
||||
@Throws(RemoteException::class)
|
||||
fun incrementalResultsConsumer_processInlineFunctions(functions: Collection<JsInlineFunctionHash>)
|
||||
|
||||
@Throws(RemoteException::class)
|
||||
fun incrementalResultsConsumer_processPackageMetadata(packageName: String, metadata: ByteArray)
|
||||
|
||||
// ---------------------------------------------------
|
||||
// IncrementalDataProvider (js)
|
||||
@Throws(RemoteException::class)
|
||||
@@ -125,9 +122,6 @@ interface CompilerCallbackServicesFacade : Remote {
|
||||
|
||||
@Throws(RemoteException::class)
|
||||
fun incrementalDataProvider_getMetadataVersion(): IntArray
|
||||
|
||||
@Throws(RemoteException::class)
|
||||
fun incrementalDataProvider_getPackageMetadata(): Collection<PackageMetadata>
|
||||
}
|
||||
|
||||
class CompiledPackagePart(
|
||||
@@ -135,17 +129,6 @@ class CompiledPackagePart(
|
||||
val metadata: ByteArray, val binaryAst: ByteArray, val inlineData: ByteArray
|
||||
) : Serializable
|
||||
|
||||
class PackageMetadata(
|
||||
val packageName: String,
|
||||
val metadata: ByteArray
|
||||
) : Serializable {
|
||||
companion object {
|
||||
// just a random number, but should never be changed to avoid deserialization problems
|
||||
private val serialVersionUID: Long = 54021986502349756L
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class RmiFriendlyCompilationCanceledException : Exception(), Serializable {
|
||||
companion object {
|
||||
// just a random number, but should never be changed to avoid deserialization problems
|
||||
|
||||
@@ -33,14 +33,4 @@ class RemoteIncrementalDataProvider(val facade: CompilerCallbackServicesFacade,
|
||||
get() = rpcProfiler.withMeasure(this) {
|
||||
facade.incrementalDataProvider_getMetadataVersion()
|
||||
}
|
||||
|
||||
override val packageMetadata: Map<String, ByteArray>
|
||||
get() = rpcProfiler.withMeasure(this) {
|
||||
val result = mutableMapOf<String, ByteArray>()
|
||||
facade.incrementalDataProvider_getPackageMetadata().forEach {
|
||||
val prev = result.put(it.packageName, it.metadata)
|
||||
check(prev == null) { "packageMetadata: duplicated entry for package `${it.packageName}`" }
|
||||
}
|
||||
result
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@ import java.io.File
|
||||
|
||||
class RemoteIncrementalResultsConsumer(val facade: CompilerCallbackServicesFacade, eventManager: EventManager, val rpcProfiler: Profiler) :
|
||||
IncrementalResultsConsumer {
|
||||
|
||||
init {
|
||||
eventManager.
|
||||
onCompilationFinished(this::flush)
|
||||
@@ -43,12 +42,6 @@ class RemoteIncrementalResultsConsumer(val facade: CompilerCallbackServicesFacad
|
||||
|
||||
override fun processInlineFunctions(functions: Collection<JsInlineFunctionHash>) = error("Should not be called in Daemon Server")
|
||||
|
||||
override fun processPackageMetadata(packageName: String, metadata: ByteArray) {
|
||||
rpcProfiler.withMeasure(this) {
|
||||
facade.incrementalResultsConsumer_processPackageMetadata(packageName, metadata)
|
||||
}
|
||||
}
|
||||
|
||||
fun flush() {
|
||||
rpcProfiler.withMeasure(this) {
|
||||
facade.incrementalResultsConsumer_processInlineFunctions(deferInlineFuncs.map {
|
||||
|
||||
@@ -8,35 +8,30 @@ package org.jetbrains.kotlin.fir.symbols
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
|
||||
abstract class ConeClassifierLookupTag {
|
||||
abstract val name: Name
|
||||
interface ConeClassifierLookupTag {
|
||||
val name: Name
|
||||
}
|
||||
|
||||
abstract class ConeClassifierLookupTagWithFixedSymbol : ConeClassifierLookupTag() {
|
||||
abstract val symbol: ConeClassifierSymbol
|
||||
interface ConeClassifierLookupTagWithFixedSymbol {
|
||||
val symbol: ConeClassifierSymbol
|
||||
}
|
||||
|
||||
data class ConeTypeParameterLookupTag(val typeParameterSymbol: ConeTypeParameterSymbol) : ConeClassifierLookupTagWithFixedSymbol() {
|
||||
override val name: Name get() = typeParameterSymbol.name
|
||||
override val symbol: ConeClassifierSymbol
|
||||
get() = typeParameterSymbol
|
||||
interface ConeTypeParameterLookupTag : ConeClassifierLookupTag {
|
||||
override val name: Name
|
||||
|
||||
}
|
||||
|
||||
abstract class ConeClassLikeLookupTag : ConeClassifierLookupTag() {
|
||||
abstract val classId: ClassId
|
||||
interface ConeClassLikeLookupTag : ConeClassifierLookupTag {
|
||||
val classId: ClassId
|
||||
|
||||
override val name: Name
|
||||
get() = classId.shortClassName
|
||||
}
|
||||
|
||||
abstract class ConeTypeAliasLookupTag : ConeClassLikeLookupTag()
|
||||
interface ConeTypeAliasLookupTag : ConeClassLikeLookupTag
|
||||
|
||||
abstract class ConeClassLookupTag : ConeClassLikeLookupTag()
|
||||
|
||||
class ConeClassLikeLookupTagImpl(override val classId: ClassId) : ConeClassLikeLookupTag() {
|
||||
var boundSymbol: Pair<*, *>? = null
|
||||
interface ConeClassLookupTag : ConeClassLikeLookupTag
|
||||
|
||||
class ConeClassLikeLookupTagImpl(override val classId: ClassId) : ConeClassLikeLookupTag {
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (javaClass != other?.javaClass) return false
|
||||
|
||||
@@ -16,9 +16,8 @@ interface ConeClassifierSymbol : ConeSymbol, TypeParameterMarker {
|
||||
fun toLookupTag(): ConeClassifierLookupTag
|
||||
}
|
||||
|
||||
interface ConeTypeParameterSymbol : ConeClassifierSymbol {
|
||||
override fun toLookupTag(): ConeTypeParameterLookupTag = ConeTypeParameterLookupTag(this)
|
||||
val name: Name
|
||||
interface ConeTypeParameterSymbol : ConeClassifierSymbol, ConeTypeParameterLookupTag {
|
||||
override fun toLookupTag(): ConeTypeParameterLookupTag = this
|
||||
}
|
||||
|
||||
interface ConeClassLikeSymbol : ConeClassifierSymbol, TypeConstructorMarker {
|
||||
|
||||
@@ -1212,16 +1212,8 @@ class HtmlFirDump internal constructor(private var linkResolver: FirLinkResolver
|
||||
is FirNamedArgumentExpression -> {
|
||||
simpleName(expression.name)
|
||||
+" = "
|
||||
if (expression.isSpread) {
|
||||
+"*"
|
||||
}
|
||||
generate(expression.expression)
|
||||
}
|
||||
is FirSpreadArgumentExpression -> {
|
||||
+"*"
|
||||
generate(expression.expression)
|
||||
|
||||
}
|
||||
is FirLambdaArgumentExpression -> {
|
||||
keyword("lambda")
|
||||
+" = "
|
||||
|
||||
@@ -21,9 +21,6 @@ import org.jetbrains.kotlin.fir.resolve.buildUseSiteScope
|
||||
import org.jetbrains.kotlin.fir.resolve.toSymbol
|
||||
import org.jetbrains.kotlin.fir.scopes.ProcessorAction
|
||||
import org.jetbrains.kotlin.fir.scopes.impl.FirClassSubstitutionScope
|
||||
import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTag
|
||||
import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTagImpl
|
||||
import org.jetbrains.kotlin.fir.symbols.ConeClassifierLookupTag
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol
|
||||
@@ -1163,19 +1160,4 @@ internal class Fir2IrVisitor(
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun visitResolvedQualifier(resolvedQualifier: FirResolvedQualifier, data: Any?): IrElement {
|
||||
val classId = resolvedQualifier.classId
|
||||
if (classId != null) {
|
||||
val classSymbol = ConeClassLikeLookupTagImpl(classId).toSymbol(session)!!
|
||||
return resolvedQualifier.convertWithOffsets { startOffset, endOffset ->
|
||||
IrGetObjectValueImpl(
|
||||
startOffset, endOffset,
|
||||
resolvedQualifier.typeRef.toIrType(session, declarationStorage),
|
||||
classSymbol.toIrSymbol(session, declarationStorage) as IrClassSymbol
|
||||
)
|
||||
}
|
||||
}
|
||||
return super.visitResolvedQualifier(resolvedQualifier, data)
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,6 @@ import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.resolve.FirSymbolProvider
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.platform.TargetPlatform
|
||||
|
||||
class FirModuleDescriptor(val session: FirSession) : ModuleDescriptor {
|
||||
override val builtIns: KotlinBuiltIns
|
||||
@@ -26,9 +25,6 @@ class FirModuleDescriptor(val session: FirSession) : ModuleDescriptor {
|
||||
return false
|
||||
}
|
||||
|
||||
override val platform: TargetPlatform?
|
||||
get() = null
|
||||
|
||||
override fun getPackage(fqName: FqName): PackageViewDescriptor {
|
||||
val symbolProvider = FirSymbolProvider.getInstance(session)
|
||||
if (symbolProvider.getPackage(fqName) != null) {
|
||||
|
||||
@@ -1267,11 +1267,6 @@ public class Fir2IrTextTestGenerated extends AbstractFir2IrTextTest {
|
||||
runTest("compiler/testData/ir/irText/expressions/whenReturn.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("whenUnusedExpression.kt")
|
||||
public void testWhenUnusedExpression() throws Exception {
|
||||
runTest("compiler/testData/ir/irText/expressions/whenUnusedExpression.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("whenWithSubjectVariable.kt")
|
||||
public void testWhenWithSubjectVariable() throws Exception {
|
||||
runTest("compiler/testData/ir/irText/expressions/whenWithSubjectVariable.kt");
|
||||
|
||||
@@ -15,7 +15,6 @@ import org.jetbrains.kotlin.fir.resolve.FirSymbolProvider
|
||||
import org.jetbrains.kotlin.fir.resolve.impl.FirCompositeSymbolProvider
|
||||
import org.jetbrains.kotlin.fir.resolve.impl.FirDependenciesSymbolProviderImpl
|
||||
import org.jetbrains.kotlin.fir.resolve.impl.FirLibrarySymbolProviderImpl
|
||||
import org.jetbrains.kotlin.fir.scopes.impl.FirClassDeclaredMemberScopeProvider
|
||||
import org.jetbrains.kotlin.load.java.JavaClassFinder
|
||||
import org.jetbrains.kotlin.load.java.JavaClassFinderImpl
|
||||
import org.jetbrains.kotlin.load.kotlin.KotlinClassFinder
|
||||
@@ -27,23 +26,18 @@ class FirJavaModuleBasedSession(
|
||||
override val sessionProvider: FirProjectSessionProvider,
|
||||
scope: GlobalSearchScope,
|
||||
dependenciesProvider: FirSymbolProvider? = null
|
||||
) : FirModuleBasedSession(moduleInfo), FirSymbolProviderAwareSession {
|
||||
|
||||
override val firSymbolProvider: FirSymbolProvider
|
||||
|
||||
) : FirModuleBasedSession(moduleInfo) {
|
||||
init {
|
||||
sessionProvider.sessionCache[moduleInfo] = this
|
||||
firSymbolProvider = FirCompositeSymbolProvider(
|
||||
listOf(
|
||||
service<FirProvider>(),
|
||||
JavaSymbolProvider(this, sessionProvider.project, scope),
|
||||
dependenciesProvider ?: FirDependenciesSymbolProviderImpl(this)
|
||||
)
|
||||
)
|
||||
|
||||
registerComponent(
|
||||
FirSymbolProvider::class,
|
||||
firSymbolProvider
|
||||
FirCompositeSymbolProvider(
|
||||
listOf(
|
||||
service<FirProvider>(),
|
||||
JavaSymbolProvider(this, sessionProvider.project, scope),
|
||||
dependenciesProvider ?: FirDependenciesSymbolProviderImpl(this)
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -55,13 +49,11 @@ class FirLibrarySession private constructor(
|
||||
packagePartProvider: PackagePartProvider,
|
||||
kotlinClassFinder: KotlinClassFinder,
|
||||
javaClassFinder: JavaClassFinder
|
||||
) : FirSessionBase(), FirSymbolProviderAwareSession {
|
||||
|
||||
override val firSymbolProvider: FirSymbolProvider
|
||||
|
||||
) : FirSessionBase() {
|
||||
init {
|
||||
sessionProvider.sessionCache[moduleInfo] = this
|
||||
firSymbolProvider =
|
||||
registerComponent(
|
||||
FirSymbolProvider::class,
|
||||
FirCompositeSymbolProvider(
|
||||
listOf(
|
||||
KotlinDeserializedJvmSymbolsProvider(
|
||||
@@ -74,12 +66,7 @@ class FirLibrarySession private constructor(
|
||||
FirDependenciesSymbolProviderImpl(this)
|
||||
)
|
||||
)
|
||||
|
||||
registerComponent(
|
||||
FirSymbolProvider::class,
|
||||
firSymbolProvider
|
||||
)
|
||||
registerComponent(FirClassDeclaredMemberScopeProvider::class, FirClassDeclaredMemberScopeProvider())
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -23,8 +23,8 @@ import org.jetbrains.kotlin.fir.java.scopes.JavaClassUseSiteScope
|
||||
import org.jetbrains.kotlin.fir.resolve.*
|
||||
import org.jetbrains.kotlin.fir.resolve.transformers.firUnsafe
|
||||
import org.jetbrains.kotlin.fir.scopes.FirScope
|
||||
import org.jetbrains.kotlin.fir.scopes.impl.FirClassDeclaredMemberScope
|
||||
import org.jetbrains.kotlin.fir.scopes.impl.FirSuperTypeScope
|
||||
import org.jetbrains.kotlin.fir.scopes.impl.declaredMemberScope
|
||||
import org.jetbrains.kotlin.fir.symbols.CallableId
|
||||
import org.jetbrains.kotlin.fir.symbols.ConeCallableSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.ConeClassLikeSymbol
|
||||
@@ -60,7 +60,7 @@ class JavaSymbolProvider(
|
||||
|
||||
override fun getClassDeclaredMemberScope(classId: ClassId): FirScope? {
|
||||
val classSymbol = getClassLikeSymbolByFqName(classId) as? FirClassSymbol ?: return null
|
||||
return declaredMemberScope(classSymbol.fir)
|
||||
return FirClassDeclaredMemberScope(classSymbol.fir)
|
||||
}
|
||||
|
||||
override fun getClassUseSiteMemberScope(
|
||||
@@ -89,7 +89,7 @@ class JavaSymbolProvider(
|
||||
scopeSession: ScopeSession
|
||||
): JavaClassUseSiteScope {
|
||||
return scopeSession.getOrBuild(regularClass.symbol, JAVA_USE_SITE) {
|
||||
val declaredScope = scopeSession.getOrBuild(regularClass.symbol, DECLARED) { declaredMemberScope(regularClass) }
|
||||
val declaredScope = scopeSession.getOrBuild(regularClass.symbol, DECLARED) { FirClassDeclaredMemberScope(regularClass) }
|
||||
val superTypeEnhancementScopes =
|
||||
lookupSuperTypes(regularClass, lookupInterfaces = true, deep = false, useSiteSession = useSiteSession)
|
||||
.mapNotNull { useSiteSuperType ->
|
||||
@@ -220,8 +220,7 @@ class JavaSymbolProvider(
|
||||
FirResolvedTypeRefImpl(
|
||||
this@JavaSymbolProvider.session, null,
|
||||
firSymbol.constructType(
|
||||
classTypeParameters.map { ConeTypeParameterTypeImpl(it.symbol.toLookupTag(), false) }.toTypedArray(),
|
||||
false
|
||||
classTypeParameters.map { ConeTypeParameterTypeImpl(it.symbol, false) }.toTypedArray(), false
|
||||
)
|
||||
)
|
||||
).apply {
|
||||
|
||||
@@ -160,7 +160,7 @@ internal fun JavaClassifierType.toConeKotlinTypeWithNullability(
|
||||
}
|
||||
is JavaTypeParameter -> {
|
||||
val symbol = javaTypeParameterStack[classifier]
|
||||
ConeTypeParameterTypeImpl(symbol.toLookupTag(), isNullable)
|
||||
ConeTypeParameterTypeImpl(symbol, isNullable)
|
||||
}
|
||||
else -> ConeClassErrorType(reason = "Unexpected classifier: $classifier")
|
||||
}
|
||||
|
||||
@@ -27,8 +27,9 @@ import org.jetbrains.kotlin.fir.references.FirErrorNamedReference
|
||||
import org.jetbrains.kotlin.fir.references.FirResolvedCallableReferenceImpl
|
||||
import org.jetbrains.kotlin.fir.resolve.*
|
||||
import org.jetbrains.kotlin.fir.resolve.transformers.firSafeNullable
|
||||
import org.jetbrains.kotlin.fir.resolve.transformers.firUnsafe
|
||||
import org.jetbrains.kotlin.fir.scopes.FirScope
|
||||
import org.jetbrains.kotlin.fir.scopes.impl.declaredMemberScope
|
||||
import org.jetbrains.kotlin.fir.scopes.impl.FirClassDeclaredMemberScope
|
||||
import org.jetbrains.kotlin.fir.service
|
||||
import org.jetbrains.kotlin.fir.symbols.*
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol
|
||||
@@ -287,7 +288,7 @@ class KotlinDeserializedJvmSymbolsProvider(
|
||||
result += FirAnnotationCallImpl(session, null, null, symbol.toDefaultResolvedTypeRef(annotationClassId)).apply {
|
||||
for ((name, expression) in argumentMap) {
|
||||
arguments += FirNamedArgumentExpressionImpl(
|
||||
this@KotlinDeserializedJvmSymbolsProvider.session, null, name, false, expression
|
||||
this@KotlinDeserializedJvmSymbolsProvider.session, null, name, expression
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -392,9 +393,7 @@ class KotlinDeserializedJvmSymbolsProvider(
|
||||
}
|
||||
|
||||
override fun getClassDeclaredMemberScope(classId: ClassId) =
|
||||
findRegularClass(classId)?.let {
|
||||
declaredMemberScope(it)
|
||||
}
|
||||
findRegularClass(classId)?.let(::FirClassDeclaredMemberScope)
|
||||
|
||||
private fun getPackageParts(packageFqName: FqName): Collection<PackagePartsCacheData> {
|
||||
return packagePartsCache.getOrPut(packageFqName) {
|
||||
|
||||
@@ -149,7 +149,7 @@ private fun JavaClassifierType.enhanceInflexibleType(
|
||||
val kotlinClassId = mappedId ?: classId
|
||||
ConeClassLikeLookupTagImpl(kotlinClassId)
|
||||
}
|
||||
is JavaTypeParameter -> javaTypeParameterStack[classifier].toLookupTag()
|
||||
is JavaTypeParameter -> javaTypeParameterStack[classifier]
|
||||
else -> return toNotNullConeKotlinType(session, javaTypeParameterStack)
|
||||
}
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ class JavaClassUseSiteScope(
|
||||
if (overriddenInJava.typeParameters.size != base.typeParameters.size) return false
|
||||
|
||||
val types = base.typeParameters.map {
|
||||
ConeTypeParameterTypeImpl(it.symbol.toLookupTag(), false)
|
||||
ConeTypeParameterTypeImpl(it.symbol, false)
|
||||
}
|
||||
val substitution = ConeSubstitutorByMap(overriddenInJava.typeParameters.map { it.symbol }.zip(types).toMap())
|
||||
if (!overriddenInJava.typeParameters.zip(base.typeParameters).all { (a, b) ->
|
||||
|
||||
@@ -174,7 +174,7 @@ class RawFirBuilder(val session: FirSession, val stubMode: Boolean) {
|
||||
} else {
|
||||
FirSingleExpressionBlock(
|
||||
session,
|
||||
FirExpressionStub(session, this).toReturn()
|
||||
FirExpressionStub(session, null).toReturn()
|
||||
)
|
||||
}
|
||||
else -> {
|
||||
@@ -199,12 +199,7 @@ class RawFirBuilder(val session: FirSession, val stubMode: Boolean) {
|
||||
{ expression }.toFirExpression("Argument is absent")
|
||||
}
|
||||
}
|
||||
val isSpread = getSpreadElement() != null
|
||||
return when {
|
||||
name != null -> FirNamedArgumentExpressionImpl(session, expression, name, isSpread, firExpression)
|
||||
isSpread -> FirSpreadArgumentExpressionImpl(session, expression, firExpression)
|
||||
else -> firExpression
|
||||
}
|
||||
return if (name != null) FirNamedArgumentExpressionImpl(session, expression, name, firExpression) else firExpression
|
||||
}
|
||||
|
||||
private fun KtPropertyAccessor?.toFirPropertyAccessor(
|
||||
@@ -450,7 +445,7 @@ class RawFirBuilder(val session: FirSession, val stubMode: Boolean) {
|
||||
this,
|
||||
ConeClassTypeImpl(
|
||||
firClass.symbol.toLookupTag(),
|
||||
typeParameters.map { ConeTypeParameterTypeImpl(it.symbol.toLookupTag(), false) }.toTypedArray(),
|
||||
typeParameters.map { ConeTypeParameterTypeImpl(it.symbol, false) }.toTypedArray(),
|
||||
false
|
||||
)
|
||||
)
|
||||
@@ -732,7 +727,7 @@ class RawFirBuilder(val session: FirSession, val stubMode: Boolean) {
|
||||
private fun typeParametersFromSelfType(delegatedSelfTypeRef: FirTypeRef): List<FirTypeParameter> {
|
||||
return delegatedSelfTypeRef.coneTypeSafe<ConeKotlinType>()
|
||||
?.typeArguments
|
||||
?.map { ((it as ConeTypeParameterType).lookupTag.symbol as FirTypeParameterSymbol).fir }
|
||||
?.map { ((it as ConeTypeParameterType).lookupTag as FirTypeParameterSymbol).fir }
|
||||
?: emptyList()
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,8 @@ FILE: annotated.kt
|
||||
super<kotlin/Any>()
|
||||
}
|
||||
|
||||
public final fun copy(): R|Two| {
|
||||
public final fun copy(): <implicit> {
|
||||
^copy R|/Two.Two|()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -25,7 +25,8 @@ FILE: destructuring.kt
|
||||
^component3 R|/Some.third|
|
||||
}
|
||||
|
||||
public final fun copy(first: Int = R|/Some.first|, second: Double = R|/Some.second|, third: String = R|/Some.third|): R|Some| {
|
||||
public final fun copy(first: Int = R|/Some.first|, second: Double = R|/Some.second|, third: String = R|/Some.third|): <implicit> {
|
||||
^copy R|/Some.Some|(R|<local>/first|, R|<local>/second|, R|<local>/third|)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -43,7 +43,8 @@ FILE: for.kt
|
||||
^component2 R|/Some.y|
|
||||
}
|
||||
|
||||
public final fun copy(x: Int = R|/Some.x|, y: Int = R|/Some.y|): R|Some| {
|
||||
public final fun copy(x: Int = R|/Some.x|, y: Int = R|/Some.y|): <implicit> {
|
||||
^copy R|/Some.Some|(R|<local>/x|, R|<local>/y|)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,7 +18,8 @@ FILE: lambda.kt
|
||||
^component2 R|/Tuple.y|
|
||||
}
|
||||
|
||||
public final fun copy(x: Int = R|/Tuple.x|, y: Int = R|/Tuple.y|): R|Tuple| {
|
||||
public final fun copy(x: Int = R|/Tuple.x|, y: Int = R|/Tuple.y|): <implicit> {
|
||||
^copy R|/Tuple.Tuple|(R|<local>/x|, R|<local>/y|)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ package org.jetbrains.kotlin.fir
|
||||
import org.jetbrains.kotlin.analyzer.ModuleInfo
|
||||
import org.jetbrains.kotlin.fir.resolve.*
|
||||
import org.jetbrains.kotlin.fir.resolve.impl.*
|
||||
import org.jetbrains.kotlin.fir.scopes.impl.FirClassDeclaredMemberScopeProvider
|
||||
|
||||
abstract class FirModuleBasedSession(override val moduleInfo: ModuleInfo) : FirSessionBase() {
|
||||
init {
|
||||
@@ -16,7 +15,6 @@ abstract class FirModuleBasedSession(override val moduleInfo: ModuleInfo) : FirS
|
||||
registerComponent(FirProvider::class, firProvider)
|
||||
registerComponent(FirQualifierResolver::class, FirQualifierResolverImpl(this))
|
||||
registerComponent(FirTypeResolver::class, FirTypeResolverImpl(this))
|
||||
registerComponent(FirClassDeclaredMemberScopeProvider::class, FirClassDeclaredMemberScopeProvider())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ abstract class AbstractAnnotationDeserializer(
|
||||
val parameter = parameterByName[name] ?: return@mapNotNull null
|
||||
val value = resolveValue(parameter.returnTypeRef, it.value, nameResolver) ?: return@mapNotNull null
|
||||
FirNamedArgumentExpressionImpl(
|
||||
session, null, name, false, value
|
||||
session, null, name, value
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -142,7 +142,29 @@ abstract class AbstractAnnotationDeserializer(
|
||||
)
|
||||
}
|
||||
// ARRAY -> {
|
||||
// TODO: see AnnotationDeserializer
|
||||
// val expectedIsArray = KotlinBuiltIns.isArray(expectedType) || KotlinBuiltIns.isPrimitiveArray(expectedType)
|
||||
// val arrayElements = value.arrayElementList
|
||||
//
|
||||
// val actualArrayType =
|
||||
// if (arrayElements.isNotEmpty()) {
|
||||
// val actualElementType = resolveArrayElementType(arrayElements.first(), nameResolver)
|
||||
// builtIns.getPrimitiveArrayKotlinTypeByPrimitiveKotlinType(actualElementType)
|
||||
// ?: builtIns.getArrayType(Variance.INVARIANT, actualElementType)
|
||||
// } else {
|
||||
// // In the case of empty array, no element has the element type, so we fall back to the expected type, if any.
|
||||
// // This is not very accurate when annotation class has been changed without recompiling clients,
|
||||
// // but should not in fact matter because the value is empty anyway
|
||||
// if (expectedIsArray) expectedType else builtIns.getArrayType(Variance.INVARIANT, builtIns.anyType)
|
||||
// }
|
||||
//
|
||||
// val expectedElementType = builtIns.getArrayElementType(if (expectedIsArray) expectedType else actualArrayType)
|
||||
//
|
||||
// ConstantValueFactory.createArrayValue(
|
||||
// arrayElements.map {
|
||||
// resolveValue(expectedElementType, it, nameResolver)
|
||||
// },
|
||||
// actualArrayType
|
||||
// )
|
||||
// }
|
||||
// else -> error("Unsupported annotation argument type: ${value.type} (expected $expectedType)")
|
||||
else -> return null
|
||||
@@ -151,4 +173,4 @@ abstract class AbstractAnnotationDeserializer(
|
||||
}
|
||||
|
||||
private fun <T> const(kind: IrConstKind<T>, value: T) = FirConstExpressionImpl(session, null, kind, value)
|
||||
}
|
||||
}
|
||||
@@ -247,7 +247,7 @@ class FirMemberDeserializer(private val c: FirDeserializationContext) {
|
||||
null,
|
||||
ConeClassTypeImpl(
|
||||
klass.symbol.toLookupTag(),
|
||||
typeParameters.map { ConeTypeParameterTypeImpl(it.symbol.toLookupTag(), false) }.toTypedArray(),
|
||||
typeParameters.map { ConeTypeParameterTypeImpl(it.symbol, false) }.toTypedArray(),
|
||||
false
|
||||
)
|
||||
)
|
||||
|
||||
@@ -57,7 +57,7 @@ class FirTypeDeserializer(
|
||||
|
||||
|
||||
private fun typeParameterSymbol(typeParameterId: Int): ConeTypeParameterLookupTag? =
|
||||
typeParameterDescriptors[typeParameterId]?.toLookupTag() ?: parent?.typeParameterSymbol(typeParameterId)
|
||||
typeParameterDescriptors[typeParameterId] ?: parent?.typeParameterSymbol(typeParameterId)
|
||||
|
||||
|
||||
private fun ProtoBuf.TypeParameter.Variance.convertVariance(): Variance {
|
||||
@@ -150,7 +150,7 @@ class FirTypeDeserializer(
|
||||
val name = nameResolver.getString(proto.typeParameterName)
|
||||
|
||||
// TODO: Optimize
|
||||
ownTypeParameters.find { it.name.asString() == name }?.toLookupTag()
|
||||
ownTypeParameters.find { it.name.asString() == name }
|
||||
}
|
||||
else -> null
|
||||
}
|
||||
|
||||
@@ -21,15 +21,7 @@ interface FirSymbolProvider {
|
||||
|
||||
fun getSymbolByLookupTag(lookupTag: ConeClassifierLookupTag): ConeClassifierSymbol? {
|
||||
return when (lookupTag) {
|
||||
is ConeClassLikeLookupTag -> {
|
||||
(lookupTag as? ConeClassLikeLookupTagImpl)
|
||||
?.boundSymbol?.takeIf { it.first === this }?.let { return it.second as ConeClassifierSymbol? }
|
||||
|
||||
getClassLikeSymbolByFqName(lookupTag.classId).also {
|
||||
(lookupTag as? ConeClassLikeLookupTagImpl)
|
||||
?.boundSymbol = Pair(this, it)
|
||||
}
|
||||
}
|
||||
is ConeClassLikeLookupTag -> getClassLikeSymbolByFqName(lookupTag.classId)
|
||||
is ConeClassifierLookupTagWithFixedSymbol -> lookupTag.symbol
|
||||
else -> error("Unknown lookupTag type: ${lookupTag::class}")
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
package org.jetbrains.kotlin.fir.resolve
|
||||
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.FirSymbolProviderAwareSession
|
||||
import org.jetbrains.kotlin.fir.declarations.*
|
||||
import org.jetbrains.kotlin.fir.render
|
||||
import org.jetbrains.kotlin.fir.service
|
||||
@@ -32,13 +31,8 @@ inline fun <K, V, VA : V> MutableMap<K, V>.getOrPut(key: K, defaultValue: (K) ->
|
||||
}
|
||||
}
|
||||
|
||||
fun ConeClassLikeLookupTag.toSymbol(useSiteSession: FirSession): ConeClassifierSymbol? {
|
||||
val firSymbolProvider =
|
||||
(useSiteSession as? FirSymbolProviderAwareSession)?.firSymbolProvider
|
||||
?: useSiteSession.getService(FirSymbolProvider::class)
|
||||
|
||||
return firSymbolProvider.getSymbolByLookupTag(this)
|
||||
}
|
||||
fun ConeClassLikeLookupTag.toSymbol(useSiteSession: FirSession): ConeClassifierSymbol? =
|
||||
useSiteSession.getService(FirSymbolProvider::class).getSymbolByLookupTag(this)
|
||||
|
||||
fun ConeAbbreviatedType.directExpansionType(useSiteSession: FirSession): ConeClassLikeType? =
|
||||
abbreviationLookupTag
|
||||
@@ -48,7 +42,7 @@ fun ConeAbbreviatedType.directExpansionType(useSiteSession: FirSession): ConeCla
|
||||
fun ConeClassifierLookupTag.toSymbol(useSiteSession: FirSession): ConeClassifierSymbol? =
|
||||
when (this) {
|
||||
is ConeClassLikeLookupTag -> toSymbol(useSiteSession)
|
||||
is ConeTypeParameterLookupTag -> this.symbol
|
||||
is ConeTypeParameterSymbol -> this
|
||||
else -> error("sealed ${this::class}")
|
||||
}
|
||||
|
||||
@@ -67,7 +61,7 @@ fun ConeClassifierLookupTag.constructType(typeArguments: Array<ConeKotlinTypePro
|
||||
fun ConeClassifierSymbol.constructType(typeArguments: Array<ConeKotlinTypeProjection>, isNullable: Boolean): ConeLookupTagBasedType {
|
||||
return when (this) {
|
||||
is ConeTypeParameterSymbol -> {
|
||||
ConeTypeParameterTypeImpl(this.toLookupTag(), isNullable)
|
||||
ConeTypeParameterTypeImpl(this, isNullable)
|
||||
}
|
||||
is ConeClassSymbol -> {
|
||||
ConeClassTypeImpl(this.toLookupTag(), typeArguments, isNullable)
|
||||
|
||||
@@ -66,7 +66,7 @@ fun FirTypeAlias.buildUseSiteScope(useSiteSession: FirSession, builder: ScopeSes
|
||||
fun FirRegularClass.buildDefaultUseSiteScope(useSiteSession: FirSession, builder: ScopeSession): FirScope {
|
||||
return builder.getOrBuild(symbol, USE_SITE) {
|
||||
|
||||
val declaredScope = builder.getOrBuild(this.symbol, DECLARED) { declaredMemberScope(this) }
|
||||
val declaredScope = builder.getOrBuild(this.symbol, DECLARED) { FirClassDeclaredMemberScope(this) }
|
||||
val scopes = lookupSuperTypes(this, lookupInterfaces = true, deep = false, useSiteSession = useSiteSession)
|
||||
.mapNotNull { useSiteSuperType ->
|
||||
if (useSiteSuperType is ConeClassErrorType) return@mapNotNull null
|
||||
|
||||
@@ -54,7 +54,18 @@ fun resolveArgumentExpression(
|
||||
is FirCallableReferenceAccess -> Unit
|
||||
// TODO:!
|
||||
//TODO: Collection literal
|
||||
is FirWrappedArgumentExpression -> resolveArgumentExpression(
|
||||
is FirLambdaArgumentExpression -> resolveArgumentExpression(
|
||||
csBuilder,
|
||||
argument.expression,
|
||||
expectedType,
|
||||
expectedTypeRef,
|
||||
sink,
|
||||
isReceiver,
|
||||
isSafeCall,
|
||||
acceptLambdaAtoms,
|
||||
typeProvider
|
||||
)
|
||||
is FirNamedArgumentExpression -> resolveArgumentExpression(
|
||||
csBuilder,
|
||||
argument.expression,
|
||||
expectedType,
|
||||
@@ -169,7 +180,7 @@ internal fun FirExpression.getExpectedType(
|
||||
// if (this.isSpread || this.isArrayAssignedAsNamedArgumentInAnnotation(parameter, languageVersionSettings)) {
|
||||
// parameter.type.unwrap()
|
||||
// } else {
|
||||
if (parameter.isVararg && (this !is FirWrappedArgumentExpression || !isSpread)) {
|
||||
if (parameter.isVararg) {
|
||||
parameter.returnTypeRef.coneTypeUnsafe<ConeKotlinType>().varargElementType(session)
|
||||
} else {
|
||||
parameter.returnTypeRef.coneTypeUnsafe()
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user