Add isData() to ClassDescriptor
This commit is contained in:
@@ -100,6 +100,11 @@ public class MutableClassDescriptor extends ClassDescriptorBase implements Class
|
||||
return isInner;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isData() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCompanionObject() {
|
||||
return false;
|
||||
|
||||
+14
@@ -34,6 +34,7 @@ import org.jetbrains.kotlin.descriptors.*;
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
|
||||
import org.jetbrains.kotlin.descriptors.impl.ClassDescriptorBase;
|
||||
import org.jetbrains.kotlin.incremental.components.NoLookupLocation;
|
||||
import org.jetbrains.kotlin.lexer.JetTokens;
|
||||
import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.psi.*;
|
||||
import org.jetbrains.kotlin.resolve.*;
|
||||
@@ -83,6 +84,7 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
||||
private final Visibility visibility;
|
||||
private final NotNullLazyValue<ClassKind> kind;
|
||||
private final NotNullLazyValue<Boolean> isInner;
|
||||
private final NotNullLazyValue<Boolean> isData;
|
||||
|
||||
private final Annotations annotations;
|
||||
private final Annotations danglingAnnotations;
|
||||
@@ -153,6 +155,13 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
||||
}
|
||||
});
|
||||
|
||||
this.isData = storageManager.createLazyValue(new Function0<Boolean>() {
|
||||
@Override
|
||||
public Boolean invoke() {
|
||||
return modifierList != null && modifierList.hasModifier(JetTokens.DATA_KEYWORD);
|
||||
}
|
||||
});
|
||||
|
||||
this.kind = storageManager.createLazyValue(new Function0<ClassKind>() {
|
||||
@Override
|
||||
public ClassKind invoke() {
|
||||
@@ -405,6 +414,11 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
||||
return isInner.invoke();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isData() {
|
||||
return isData.invoke();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCompanionObject() {
|
||||
return isCompanionObject;
|
||||
|
||||
+2
-1
@@ -125,7 +125,8 @@ public class DescriptorSerializer {
|
||||
ProtoBuf.Class.Builder builder = ProtoBuf.Class.newBuilder();
|
||||
|
||||
int flags = Flags.getClassFlags(hasAnnotations(classDescriptor), classDescriptor.getVisibility(), classDescriptor.getModality(),
|
||||
classDescriptor.getKind(), classDescriptor.isInner(), classDescriptor.isCompanionObject());
|
||||
classDescriptor.getKind(), classDescriptor.isInner(), classDescriptor.isCompanionObject(),
|
||||
classDescriptor.isData());
|
||||
if (flags != builder.getFlags()) {
|
||||
builder.setFlags(flags);
|
||||
}
|
||||
|
||||
+2
-1
@@ -39,7 +39,7 @@ import org.jetbrains.kotlin.resolve.scopes.JetScope
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.utils.addIfNotNull
|
||||
import org.jetbrains.kotlin.utils.toReadOnlyList
|
||||
import java.util.ArrayList
|
||||
import java.util.*
|
||||
|
||||
class LazyJavaClassDescriptor(
|
||||
private val outerC: LazyJavaResolverContext,
|
||||
@@ -73,6 +73,7 @@ class LazyJavaClassDescriptor(
|
||||
override fun getModality() = modality
|
||||
override fun getVisibility() = visibility
|
||||
override fun isInner() = isInner
|
||||
override fun isData() = false
|
||||
|
||||
private val typeConstructor = c.storageManager.createLazyValue { LazyJavaClassTypeConstructor() }
|
||||
override fun getTypeConstructor(): TypeConstructor = typeConstructor()
|
||||
|
||||
+2
-1
@@ -30,7 +30,7 @@ import org.jetbrains.kotlin.resolve.scopes.StaticScopeForKotlinClass
|
||||
import org.jetbrains.kotlin.storage.StorageManager
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.utils.toReadOnlyList
|
||||
import java.util.ArrayList
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
* A [ClassDescriptor] representing the fictitious class for a function type, such as kotlin.Function1 or kotlin.reflect.KFunction2.
|
||||
@@ -82,6 +82,7 @@ public class FunctionClassDescriptor(
|
||||
override fun getVisibility() = Visibilities.PUBLIC
|
||||
override fun isCompanionObject() = false
|
||||
override fun isInner() = false
|
||||
override fun isData() = false
|
||||
override fun getAnnotations() = Annotations.EMPTY
|
||||
override fun getSource() = SourceElement.NO_SOURCE
|
||||
|
||||
|
||||
@@ -87,6 +87,8 @@ public interface ClassDescriptor extends ClassifierDescriptor, MemberDescriptor,
|
||||
|
||||
boolean isCompanionObject();
|
||||
|
||||
boolean isData();
|
||||
|
||||
@NotNull
|
||||
ReceiverParameterDescriptor getThisAsReceiverParameter();
|
||||
|
||||
|
||||
@@ -133,6 +133,11 @@ public class ClassDescriptorImpl extends ClassDescriptorBase {
|
||||
return Visibilities.PUBLIC;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isData() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInner() {
|
||||
return false;
|
||||
|
||||
+5
@@ -144,6 +144,11 @@ public class EnumEntrySyntheticClassDescriptor extends ClassDescriptorBase {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isData() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCompanionObject() {
|
||||
return false;
|
||||
|
||||
+5
@@ -211,6 +211,11 @@ public class LazySubstitutingClassDescriptor implements ClassDescriptor {
|
||||
return original.isInner();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isData() {
|
||||
return original.isData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCompanionObject() {
|
||||
return original.isCompanionObject();
|
||||
|
||||
@@ -88,13 +88,15 @@ public class Flags {
|
||||
Modality modality,
|
||||
ClassKind kind,
|
||||
boolean inner,
|
||||
boolean isCompanionObject
|
||||
boolean isCompanionObject,
|
||||
boolean isData
|
||||
) {
|
||||
return HAS_ANNOTATIONS.toFlags(hasAnnotations)
|
||||
| MODALITY.toFlags(modality(modality))
|
||||
| VISIBILITY.toFlags(visibility(visibility))
|
||||
| CLASS_KIND.toFlags(classKind(kind, isCompanionObject))
|
||||
| IS_INNER.toFlags(inner)
|
||||
| IS_DATA.toFlags(isData)
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
+3
@@ -54,6 +54,7 @@ public class DeserializedClassDescriptor(
|
||||
private val kind = Deserialization.classKind(kindFromProto)
|
||||
private val isCompanion = kindFromProto == ProtoBuf.Class.Kind.COMPANION_OBJECT
|
||||
private val isInner = Flags.IS_INNER.get(classProto.getFlags())
|
||||
private val isData = Flags.IS_DATA.get(classProto.flags)
|
||||
|
||||
val c = outerContext.childContext(this, classProto.typeParameterList, nameResolver, TypeTable(classProto.typeTable))
|
||||
|
||||
@@ -90,6 +91,8 @@ public class DeserializedClassDescriptor(
|
||||
|
||||
override fun isInner() = isInner
|
||||
|
||||
override fun isData() = isData
|
||||
|
||||
override fun getAnnotations() = annotations
|
||||
|
||||
override fun getUnsubstitutedMemberScope() = memberScope
|
||||
|
||||
Reference in New Issue
Block a user