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
@@ -83,6 +83,7 @@ class SyntheticClassOrObjectDescriptor(
|
||||
override fun isExpect() = false
|
||||
override fun isActual() = false
|
||||
override fun isFun() = false
|
||||
override fun isValue() = false
|
||||
|
||||
override fun getCompanionObjectDescriptor(): ClassDescriptorWithResolutionScopes? = null
|
||||
override fun getTypeConstructor(): TypeConstructor = typeConstructor
|
||||
|
||||
+7
@@ -87,6 +87,7 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
||||
private final boolean isExpect;
|
||||
private final boolean isActual;
|
||||
private final boolean isFun;
|
||||
private final boolean isValue;
|
||||
|
||||
private final Annotations annotations;
|
||||
private final Annotations danglingAnnotations;
|
||||
@@ -160,6 +161,7 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
||||
containingDeclaration instanceof ClassDescriptor && ((ClassDescriptor) containingDeclaration).isExpect();
|
||||
|
||||
this.isFun = modifierList != null && PsiUtilsKt.hasFunModifier(modifierList);
|
||||
this.isValue = modifierList != null && PsiUtilsKt.hasValueModifier(modifierList);
|
||||
|
||||
// Annotation entries are taken from both own annotations (if any) and object literal annotations (if any)
|
||||
List<KtAnnotationEntry> annotationEntries = new ArrayList<>();
|
||||
@@ -552,6 +554,11 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
||||
return isFun;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValue() {
|
||||
return isValue;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Annotations getAnnotations() {
|
||||
|
||||
@@ -604,6 +604,9 @@ open class IrBasedClassDescriptor(owner: IrClass) : ClassDescriptor, IrBasedDecl
|
||||
|
||||
override fun isFun() = owner.isFun
|
||||
|
||||
// In IR, inline and value are synonyms
|
||||
override fun isValue() = owner.isInline
|
||||
|
||||
override fun getThisAsReceiverParameter() = owner.thisReceiver?.toIrBasedDescriptor() as ReceiverParameterDescriptor
|
||||
|
||||
override fun getUnsubstitutedPrimaryConstructor() =
|
||||
@@ -704,6 +707,8 @@ open class IrBasedEnumEntryDescriptor(owner: IrEnumEntry) : ClassDescriptor, IrB
|
||||
|
||||
override fun isFun() = false
|
||||
|
||||
override fun isValue() = false
|
||||
|
||||
override fun getThisAsReceiverParameter() = (owner.parent as IrClass).toIrBasedDescriptor().thisAsReceiverParameter
|
||||
|
||||
override fun getUnsubstitutedPrimaryConstructor(): ClassConstructorDescriptor? {
|
||||
|
||||
@@ -583,6 +583,8 @@ open class WrappedClassDescriptor : ClassDescriptor, WrappedDeclarationDescripto
|
||||
|
||||
override fun isFun() = owner.isFun
|
||||
|
||||
override fun isValue() = owner.isInline
|
||||
|
||||
override fun getThisAsReceiverParameter() = owner.thisReceiver?.descriptor as ReceiverParameterDescriptor
|
||||
|
||||
override fun getUnsubstitutedPrimaryConstructor() =
|
||||
@@ -682,6 +684,8 @@ open class WrappedScriptDescriptor : ScriptDescriptor, WrappedDeclarationDescrip
|
||||
|
||||
override fun isFun() = false
|
||||
|
||||
override fun isValue() = false
|
||||
|
||||
override fun getThisAsReceiverParameter() = owner.thisReceiver.descriptor as ReceiverParameterDescriptor
|
||||
|
||||
override fun getUnsubstitutedPrimaryConstructor() = TODO()
|
||||
@@ -822,6 +826,8 @@ open class WrappedEnumEntryDescriptor : ClassDescriptor, WrappedDeclarationDescr
|
||||
|
||||
override fun isFun() = false
|
||||
|
||||
override fun isValue() = false
|
||||
|
||||
override fun getThisAsReceiverParameter() = (owner.parent as IrClass).descriptor.thisAsReceiverParameter
|
||||
|
||||
override fun getUnsubstitutedPrimaryConstructor(): ClassConstructorDescriptor? {
|
||||
|
||||
@@ -452,6 +452,8 @@ fun KtModifierList.hasSuspendModifier() = hasModifier(KtTokens.SUSPEND_KEYWORD)
|
||||
|
||||
fun KtModifierList.hasFunModifier() = hasModifier(KtTokens.FUN_KEYWORD)
|
||||
|
||||
fun KtModifierList.hasValueModifier() = hasModifier(KtTokens.VALUE_KEYWORD)
|
||||
|
||||
fun ASTNode.children() = generateSequence(firstChildNode) { node -> node.treeNext }
|
||||
fun ASTNode.parents() = generateSequence(treeParent) { node -> node.treeParent }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user