JS: support '-Xskip-metadata-version-check' to allow pre-release libraries

This commit is contained in:
Alexander Udalov
2017-03-16 14:35:17 +03:00
parent a795a256f4
commit 30dfd5cc1b
6 changed files with 59 additions and 15 deletions
@@ -26,6 +26,7 @@ import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.serialization.ProtoBuf
import org.jetbrains.kotlin.serialization.deserialization.AnnotationDeserializer
import org.jetbrains.kotlin.serialization.deserialization.DeserializationConfiguration
import org.jetbrains.kotlin.serialization.deserialization.DeserializedPackageFragmentImpl
import org.jetbrains.kotlin.serialization.deserialization.IncompatibleVersionErrorData
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedClassDescriptor
@@ -40,8 +41,9 @@ class KotlinJavascriptPackageFragment(
storageManager: StorageManager,
module: ModuleDescriptor,
proto: ProtoBuf.PackageFragment,
header: JsProtoBuf.Header
) : DeserializedPackageFragmentImpl(fqName, storageManager, module, proto, JsContainerSource(fqName, header)) {
header: JsProtoBuf.Header,
configuration: DeserializationConfiguration
) : DeserializedPackageFragmentImpl(fqName, storageManager, module, proto, JsContainerSource(fqName, header, configuration)) {
private val fileMap: Map<Int, FileHolder> by storageManager.createLazyValue {
this.proto.getExtension(JsProtoBuf.packageFragmentFiles).fileList.withIndex().associate { (index, file) ->
(if (file.hasId()) file.id else index) to FileHolder(file.annotationList)
@@ -72,7 +74,11 @@ class KotlinJavascriptPackageFragment(
}
}
private class JsContainerSource(private val fqName: FqName, private val header: JsProtoBuf.Header) : DeserializedContainerSource {
private class JsContainerSource(
private val fqName: FqName,
header: JsProtoBuf.Header,
configuration: DeserializationConfiguration
) : DeserializedContainerSource {
// TODO
override fun getContainingFile(): SourceFile = SourceFile.NO_SOURCE_FILE
@@ -81,10 +87,9 @@ class KotlinJavascriptPackageFragment(
override val incompatibility: IncompatibleVersionErrorData<*>?
get() = null
override val isPreReleaseInvisible: Boolean
get() = (header.flags and 1) != 0 && !KotlinCompilerVersion.isPreRelease()
override val isPreReleaseInvisible: Boolean =
!configuration.skipMetadataVersionCheck && (header.flags and 1) != 0 && !KotlinCompilerVersion.isPreRelease()
// TODO: this is not a class
override val presentableString: String
get() = "Package '$fqName'"
}
@@ -34,7 +34,7 @@ fun createKotlinJavascriptPackageFragmentProvider(
): PackageFragmentProvider {
val packageFragments = packageFragmentProtos.mapNotNull { proto ->
proto.fqName?.let { fqName ->
KotlinJavascriptPackageFragment(fqName, storageManager, module, proto, header)
KotlinJavascriptPackageFragment(fqName, storageManager, module, proto, header, configuration)
}
}