kotlinx-metadata: Wrong interpretation of Flag.Constructor.IS_PRIMARY

^KT-42429
This commit is contained in:
Dmitriy Dolovov
2020-10-02 22:04:37 +03:00
parent 3a5ffe479e
commit 52e56ca070
3 changed files with 12 additions and 4 deletions
@@ -53,7 +53,7 @@ class MetadataSmokeTest {
val klass = KmClass().apply { val klass = KmClass().apply {
name = "Hello" name = "Hello"
flags = flagsOf(Flag.IS_PUBLIC) flags = flagsOf(Flag.IS_PUBLIC)
constructors += KmConstructor(flagsOf(Flag.IS_PUBLIC, Flag.Constructor.IS_PRIMARY)).apply { constructors += KmConstructor(flagsOf(Flag.IS_PUBLIC)).apply {
signature = JvmMethodSignature("<init>", "()V") signature = JvmMethodSignature("<init>", "()V")
} }
functions += KmFunction(flagsOf(Flag.IS_PUBLIC, Flag.Function.IS_DECLARATION), "hello").apply { functions += KmFunction(flagsOf(Flag.IS_PUBLIC, Flag.Function.IS_DECLARATION), "hello").apply {
@@ -219,11 +219,19 @@ class Flag(private val offset: Int, private val bitWidth: Int, private val value
* A container of flags applicable to Kotlin constructors. * A container of flags applicable to Kotlin constructors.
*/ */
object Constructor { object Constructor {
@JvmField
@Deprecated(
"Use IS_SECONDARY which holds inverted value instead.",
ReplaceWith("Flag.Constructor.IS_SECONDARY"),
level = DeprecationLevel.ERROR
)
val IS_PRIMARY = Flag(F.IS_SECONDARY, 0)
/** /**
* Signifies that the corresponding constructor is primary, i.e. declared in the class header, not in the class body. * Signifies that the corresponding constructor is secondary, i.e. declared not in the class header, but in the class body.
*/ */
@JvmField @JvmField
val IS_PRIMARY = Flag(F.IS_SECONDARY, 0) val IS_SECONDARY = Flag(F.IS_SECONDARY)
/** /**
* Signifies that the corresponding constructor has non-stable parameter names, i.e. cannot be called with named arguments. * Signifies that the corresponding constructor has non-stable parameter names, i.e. cannot be called with named arguments.
@@ -958,7 +958,7 @@ private val CLASS_FLAGS_MAP = COMMON_FLAGS_MAP + mapOf(
) )
private val CONSTRUCTOR_FLAGS_MAP = VISIBILITY_FLAGS_MAP + mapOf( private val CONSTRUCTOR_FLAGS_MAP = VISIBILITY_FLAGS_MAP + mapOf(
Flag.Constructor.IS_PRIMARY to "/* primary */", Flag.Constructor.IS_SECONDARY to "/* secondary */",
Flag.Constructor.HAS_NON_STABLE_PARAMETER_NAMES to "/* non-stable parameter names */" Flag.Constructor.HAS_NON_STABLE_PARAMETER_NAMES to "/* non-stable parameter names */"
) )