Write "pre-release" flag to class files, do not allow usages in release

This commit is contained in:
Alexander Udalov
2016-12-07 14:22:29 +03:00
parent 1342743001
commit 4e99349f1f
13 changed files with 125 additions and 36 deletions
@@ -16,6 +16,7 @@
package org.jetbrains.kotlin.load.kotlin
import org.jetbrains.kotlin.config.KotlinCompilerVersion
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor
import org.jetbrains.kotlin.load.kotlin.header.KotlinClassHeader
@@ -49,7 +50,7 @@ class DeserializedDescriptorResolver(private val errorReporter: ErrorReporter) {
val classData = parseProto(kotlinClass) {
JvmProtoBufUtil.readClassDataFrom(data, strings)
}
val sourceElement = KotlinJvmBinarySourceElement(kotlinClass)
val sourceElement = KotlinJvmBinarySourceElement(kotlinClass, !IS_PRE_RELEASE && kotlinClass.classHeader.isPreRelease)
return ClassDataWithSource(classData, sourceElement)
}
@@ -92,5 +93,8 @@ class DeserializedDescriptorResolver(private val errorReporter: ErrorReporter) {
private val KOTLIN_FILE_FACADE_OR_MULTIFILE_CLASS_PART =
setOf(KotlinClassHeader.Kind.FILE_FACADE, KotlinClassHeader.Kind.MULTIFILE_CLASS_PART)
var IS_PRE_RELEASE = KotlinCompilerVersion.IS_PRE_RELEASE
@Deprecated("Should only be used in tests") set
}
}
@@ -30,6 +30,9 @@ class JvmPackagePartSource(val className: JvmClassName, val facadeClassName: Jvm
}
)
// TODO
override val isPreReleaseInvisible: Boolean get() = false
val simpleName: Name get() = Name.identifier(className.internalName.substringAfterLast('/'))
val classId: ClassId get() = ClassId(className.packageFqName, simpleName)
@@ -18,8 +18,13 @@ package org.jetbrains.kotlin.load.kotlin
import org.jetbrains.kotlin.descriptors.SourceElement
import org.jetbrains.kotlin.descriptors.SourceFile
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource
class KotlinJvmBinarySourceElement(val binaryClass: KotlinJvmBinaryClass) : SourceElement {
override fun toString() = "${javaClass.simpleName}: $binaryClass"
class KotlinJvmBinarySourceElement(
val binaryClass: KotlinJvmBinaryClass,
override val isPreReleaseInvisible: Boolean = false
) : DeserializedContainerSource {
override fun getContainingFile(): SourceFile = SourceFile.NO_SOURCE_FILE
override fun toString() = "${javaClass.simpleName}: $binaryClass"
}