Add KotlinVersion.IS_PRE_RELEASE and a flag to kotlin/Metadata
This commit is contained in:
+4
-1
@@ -20,6 +20,7 @@ import org.jetbrains.kotlin.name.FqName;
|
||||
import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.resolve.jvm.JvmClassName;
|
||||
|
||||
@SuppressWarnings("PointlessBitwiseExpression")
|
||||
public final class JvmAnnotationNames {
|
||||
public static final FqName METADATA_FQ_NAME = new FqName("kotlin.Metadata");
|
||||
public static final String METADATA_DESC = "L" + JvmClassName.byFqNameWithoutInnerClasses(METADATA_FQ_NAME).getInternalName() + ";";
|
||||
@@ -32,7 +33,9 @@ public final class JvmAnnotationNames {
|
||||
public static final String METADATA_EXTRA_STRING_FIELD_NAME = "xs";
|
||||
public static final String METADATA_MULTIFILE_CLASS_NAME_FIELD_NAME = METADATA_EXTRA_STRING_FIELD_NAME;
|
||||
public static final String METADATA_EXTRA_INT_FIELD_NAME = "xi";
|
||||
public static final String METADATA_MULTIFILE_CLASS_KIND_FIELD_NAME = METADATA_EXTRA_INT_FIELD_NAME;
|
||||
|
||||
public static final int METADATA_MULTIFILE_PARTS_INHERIT_FLAG = 1 << 0;
|
||||
public static final int METADATA_PRE_RELEASE_FLAG = 1 << 1;
|
||||
|
||||
public static final Name DEFAULT_ANNOTATION_MEMBER_NAME = Name.identifier("value");
|
||||
|
||||
|
||||
+16
-13
@@ -16,8 +16,11 @@
|
||||
|
||||
package org.jetbrains.kotlin.load.kotlin.header
|
||||
|
||||
import org.jetbrains.kotlin.load.java.JvmAnnotationNames
|
||||
import org.jetbrains.kotlin.load.java.JvmBytecodeBinaryVersion
|
||||
import org.jetbrains.kotlin.load.kotlin.JvmMetadataVersion
|
||||
import org.jetbrains.kotlin.load.kotlin.header.KotlinClassHeader.MultifileClassKind.DELEGATING
|
||||
import org.jetbrains.kotlin.load.kotlin.header.KotlinClassHeader.MultifileClassKind.INHERITING
|
||||
|
||||
class KotlinClassHeader(
|
||||
val kind: KotlinClassHeader.Kind,
|
||||
@@ -45,27 +48,27 @@ class KotlinClassHeader(
|
||||
}
|
||||
}
|
||||
|
||||
// See kotlin.Metadata
|
||||
enum class MultifileClassKind(val id: Int) {
|
||||
DELEGATING(0),
|
||||
INHERITING(1);
|
||||
|
||||
companion object {
|
||||
private val entryById = values().associateBy(MultifileClassKind::id)
|
||||
|
||||
@JvmStatic
|
||||
fun getById(id: Int) = entryById[id]
|
||||
}
|
||||
enum class MultifileClassKind {
|
||||
DELEGATING,
|
||||
INHERITING;
|
||||
}
|
||||
|
||||
val multifileClassName: String?
|
||||
get() = if (kind == Kind.MULTIFILE_CLASS_PART) extraString else null
|
||||
|
||||
// TODO: use in incremental compilation
|
||||
val multifileClassKind: MultifileClassKind?
|
||||
get() = if (kind == Kind.MULTIFILE_CLASS || kind == Kind.MULTIFILE_CLASS_PART)
|
||||
MultifileClassKind.getById(extraInt)
|
||||
get() = if (kind == Kind.MULTIFILE_CLASS || kind == Kind.MULTIFILE_CLASS_PART) {
|
||||
if ((extraInt and JvmAnnotationNames.METADATA_MULTIFILE_PARTS_INHERIT_FLAG) != 0)
|
||||
INHERITING
|
||||
else
|
||||
DELEGATING
|
||||
}
|
||||
else
|
||||
null
|
||||
|
||||
val isPreRelease: Boolean
|
||||
get() = (extraInt and JvmAnnotationNames.METADATA_PRE_RELEASE_FLAG) != 0
|
||||
|
||||
override fun toString() = "$kind version=$metadataVersion"
|
||||
}
|
||||
|
||||
@@ -57,7 +57,10 @@ internal annotation class Metadata(
|
||||
*/
|
||||
val xs: String = "",
|
||||
/**
|
||||
* An extra int. For multi-file class, represents code generation scheme.
|
||||
* An extra int. Bits of this number represent the following flags:
|
||||
*
|
||||
* 0 - this is a multi-file class facade or part, compiled with `-Xmultifile-parts-inherit`.
|
||||
* 1 - this class file is compiled by a pre-release version of Kotlin and is not visible to release versions.
|
||||
*/
|
||||
val xi: Int = 0
|
||||
)
|
||||
|
||||
@@ -20,4 +20,18 @@ public class KotlinCompilerVersion {
|
||||
// The value of this constant is generated by the build script
|
||||
// DON'T MODIFY IT
|
||||
public static final String VERSION = "@snapshot@";
|
||||
|
||||
// True if this compiler is of a non-stable (EAP or Beta) version.
|
||||
// Binaries produced by this compiler can not be loaded by release versions of the compiler.
|
||||
// Change this value before and after every major release
|
||||
public static final boolean IS_PRE_RELEASE = true;
|
||||
|
||||
static {
|
||||
if (!VERSION.equals("@snapshot@") && !VERSION.contains("-") && IS_PRE_RELEASE) {
|
||||
throw new IllegalStateException(
|
||||
"IS_PRE_RELEASE cannot be false for a compiler without '-' in its version.\n" +
|
||||
"Please change IS_PRE_RELEASE to false, commit and push this change to master"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user