Value classes: Add isValue property to class descriptors
Reuse isInline flag in proto and IR. Check metadata version on deserialization.
This commit is contained in:
+1
@@ -105,6 +105,7 @@ class LazyJavaClassDescriptor(
|
||||
override fun isExpect() = false
|
||||
override fun isActual() = false
|
||||
override fun isFun() = false
|
||||
override fun isValue() = false
|
||||
|
||||
private val typeConstructor = LazyJavaClassTypeConstructor()
|
||||
override fun getTypeConstructor(): TypeConstructor = typeConstructor
|
||||
|
||||
+1
@@ -81,6 +81,7 @@ class FunctionClassDescriptor(
|
||||
override fun isData() = false
|
||||
override fun isInline() = false
|
||||
override fun isFun() = false
|
||||
override fun isValue() = false
|
||||
override fun isExpect() = false
|
||||
override fun isActual() = false
|
||||
override fun isExternal() = false
|
||||
|
||||
@@ -72,6 +72,8 @@ public interface ClassDescriptor extends ClassifierDescriptorWithTypeParameters,
|
||||
|
||||
boolean isFun();
|
||||
|
||||
boolean isValue();
|
||||
|
||||
@NotNull
|
||||
ReceiverParameterDescriptor getThisAsReceiverParameter();
|
||||
|
||||
|
||||
@@ -71,6 +71,7 @@ class NotFoundClasses(private val storageManager: StorageManager, private val mo
|
||||
override fun isData() = false
|
||||
override fun isInline() = false
|
||||
override fun isFun() = false
|
||||
override fun isValue() = false
|
||||
override fun isExpect() = false
|
||||
override fun isActual() = false
|
||||
override fun isExternal() = false
|
||||
|
||||
@@ -148,6 +148,11 @@ public class ClassDescriptorImpl extends ClassDescriptorBase {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValue() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInner() {
|
||||
return false;
|
||||
|
||||
+5
@@ -138,6 +138,11 @@ public class EnumEntrySyntheticClassDescriptor extends ClassDescriptorBase {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValue() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFun() {
|
||||
return false;
|
||||
|
||||
+5
@@ -248,6 +248,11 @@ public class LazySubstitutingClassDescriptor extends ModuleAwareClassDescriptor
|
||||
return original.isFun();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValue() {
|
||||
return original.isValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isExternal() {
|
||||
return original.isExternal();
|
||||
|
||||
@@ -104,6 +104,11 @@ public class MutableClassDescriptor extends ClassDescriptorBase {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValue() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCompanionObject() {
|
||||
return false;
|
||||
|
||||
+3
-1
@@ -98,7 +98,7 @@ class DeserializedClassDescriptor(
|
||||
|
||||
override fun isData() = Flags.IS_DATA.get(classProto.flags)
|
||||
|
||||
override fun isInline() = Flags.IS_INLINE_CLASS.get(classProto.flags)
|
||||
override fun isInline() = Flags.IS_INLINE_CLASS.get(classProto.flags) && metadataVersion.isAtMost(1, 4, 1)
|
||||
|
||||
override fun isExpect() = Flags.IS_EXPECT_CLASS.get(classProto.flags)
|
||||
|
||||
@@ -108,6 +108,8 @@ class DeserializedClassDescriptor(
|
||||
|
||||
override fun isFun() = Flags.IS_FUN_INTERFACE.get(classProto.flags)
|
||||
|
||||
override fun isValue() = Flags.IS_INLINE_CLASS.get(classProto.flags) && metadataVersion.isAtLeast(1, 4, 2)
|
||||
|
||||
override fun getUnsubstitutedMemberScope(kotlinTypeRefiner: KotlinTypeRefiner): MemberScope =
|
||||
memberScopeHolder.getScope(kotlinTypeRefiner)
|
||||
|
||||
|
||||
@@ -48,6 +48,19 @@ abstract class BinaryVersion(private vararg val numbers: Int) {
|
||||
return this.patch >= patch
|
||||
}
|
||||
|
||||
fun isAtMost(version: BinaryVersion): Boolean =
|
||||
isAtMost(version.major, version.minor, version.patch)
|
||||
|
||||
fun isAtMost(major: Int, minor: Int, patch: Int): Boolean {
|
||||
if (this.major < major) return true
|
||||
if (this.major > major) return false
|
||||
|
||||
if (this.minor < minor) return true
|
||||
if (this.minor > minor) return false
|
||||
|
||||
return this.patch <= patch
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
val versions = toArray().takeWhile { it != UNKNOWN }
|
||||
return if (versions.isEmpty()) "unknown" else versions.joinToString(".")
|
||||
|
||||
Reference in New Issue
Block a user