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