Add external property to class and property descriptors
This commit is contained in:
+1
-1
@@ -33,7 +33,7 @@ class JvmBuiltInClassDescriptorFactory(
|
||||
ClassDescriptorImpl(
|
||||
moduleDescriptor.getPackage(KOTLIN_FQ_NAME).fragments.filterIsInstance<BuiltInsPackageFragment>().first(),
|
||||
CLONEABLE_NAME, Modality.ABSTRACT, ClassKind.INTERFACE, listOf(moduleDescriptor.builtIns.anyType),
|
||||
SourceElement.NO_SOURCE
|
||||
SourceElement.NO_SOURCE, /* isExternal = */ false
|
||||
).apply {
|
||||
initialize(CloneableClassScope(storageManager, this), emptySet(), null)
|
||||
}
|
||||
|
||||
+1
-1
@@ -46,7 +46,7 @@ public class JavaPropertyDescriptor extends PropertyDescriptorImpl implements Ja
|
||||
boolean isStaticFinal
|
||||
) {
|
||||
super(containingDeclaration, original, annotations, modality, visibility, isVar, name, kind, source,
|
||||
/* lateInit = */ false, /* isConst = */ false, /* isPlatform = */ false, /* isImpl = */ false);
|
||||
/* lateInit = */ false, /* isConst = */ false, /* isPlatform = */ false, /* isImpl = */ false, /* isExternal = */ false);
|
||||
|
||||
this.isStaticFinal = isStaticFinal;
|
||||
}
|
||||
|
||||
+2
-1
@@ -55,7 +55,8 @@ class LazyJavaClassDescriptor(
|
||||
private val jClass: JavaClass,
|
||||
private val additionalSupertypeClassDescriptor: ClassDescriptor? = null
|
||||
) : ClassDescriptorBase(outerContext.storageManager, containingDeclaration, jClass.name,
|
||||
outerContext.components.sourceElementFactory.source(jClass)), JavaClassDescriptor {
|
||||
outerContext.components.sourceElementFactory.source(jClass),
|
||||
/* isExternal = */ false), JavaClassDescriptor {
|
||||
|
||||
private val c: LazyJavaResolverContext = outerContext.child(this, jClass)
|
||||
|
||||
|
||||
+5
-4
@@ -87,9 +87,9 @@ open class JvmBuiltInsSettings(
|
||||
// - Otherwise error will be reported because of Deprecated annotation with Error level
|
||||
val lowPriorityAnnotation =
|
||||
ClassDescriptorImpl(
|
||||
moduleDescriptor.getPackage(LOW_PRIORITY_IN_OVERLOAD_RESOLUTION_FQ_NAME.parent()),
|
||||
LOW_PRIORITY_IN_OVERLOAD_RESOLUTION_FQ_NAME.shortName(), Modality.FINAL, ClassKind.ANNOTATION_CLASS,
|
||||
moduleDescriptor.builtIns.anyType.singletonList(), SourceElement.NO_SOURCE
|
||||
moduleDescriptor.getPackage(LOW_PRIORITY_IN_OVERLOAD_RESOLUTION_FQ_NAME.parent()), LOW_PRIORITY_IN_OVERLOAD_RESOLUTION_FQ_NAME.shortName(),
|
||||
Modality.FINAL, ClassKind.ANNOTATION_CLASS, moduleDescriptor.builtIns.anyType.singletonList(),
|
||||
SourceElement.NO_SOURCE, /* isExternal = */ false
|
||||
).run {
|
||||
initialize(MemberScope.Empty, emptySet(), null)
|
||||
AnnotationDescriptorImpl(defaultType, emptyMap(), SourceElement.NO_SOURCE)
|
||||
@@ -112,7 +112,8 @@ open class JvmBuiltInsSettings(
|
||||
val superTypes = listOf(LazyWrappedType(this) { moduleDescriptor.builtIns.anyType })
|
||||
|
||||
val mockSerializableClass = ClassDescriptorImpl(
|
||||
mockJavaIoPackageFragment, Name.identifier("Serializable"), Modality.ABSTRACT, ClassKind.INTERFACE, superTypes, SourceElement.NO_SOURCE
|
||||
mockJavaIoPackageFragment, Name.identifier("Serializable"), Modality.ABSTRACT, ClassKind.INTERFACE, superTypes,
|
||||
SourceElement.NO_SOURCE, /* isExternal = */ false
|
||||
)
|
||||
|
||||
mockSerializableClass.initialize(MemberScope.Empty, emptySet(), null)
|
||||
|
||||
+1
@@ -104,6 +104,7 @@ class FunctionClassDescriptor(
|
||||
override fun isData() = false
|
||||
override fun isPlatform() = false
|
||||
override fun isImpl() = false
|
||||
override fun isExternal() = false
|
||||
override val annotations: Annotations get() = Annotations.EMPTY
|
||||
override fun getSource() = SourceElement.NO_SOURCE
|
||||
|
||||
|
||||
@@ -75,8 +75,6 @@ public interface FunctionDescriptor extends CallableMemberDescriptor {
|
||||
|
||||
boolean isTailrec();
|
||||
|
||||
boolean isExternal();
|
||||
|
||||
boolean isHiddenForResolutionEverywhereBesideSupercalls();
|
||||
|
||||
boolean isSuspend();
|
||||
|
||||
@@ -29,4 +29,6 @@ public interface MemberDescriptor extends DeclarationDescriptorNonRoot, Declarat
|
||||
boolean isPlatform();
|
||||
|
||||
boolean isImpl();
|
||||
|
||||
boolean isExternal();
|
||||
}
|
||||
|
||||
+2
@@ -69,6 +69,8 @@ abstract class AbstractTypeAliasDescriptor(
|
||||
|
||||
override fun isImpl(): Boolean = false
|
||||
|
||||
override fun isExternal() = false
|
||||
|
||||
override fun getTypeConstructor(): TypeConstructor =
|
||||
typeConstructor
|
||||
|
||||
|
||||
@@ -26,16 +26,24 @@ public abstract class ClassDescriptorBase extends AbstractClassDescriptor {
|
||||
|
||||
private final DeclarationDescriptor containingDeclaration;
|
||||
private final SourceElement source;
|
||||
private final boolean isExternal;
|
||||
|
||||
protected ClassDescriptorBase(
|
||||
@NotNull StorageManager storageManager,
|
||||
@NotNull DeclarationDescriptor containingDeclaration,
|
||||
@NotNull Name name,
|
||||
@NotNull SourceElement source
|
||||
@NotNull SourceElement source,
|
||||
boolean isExternal
|
||||
) {
|
||||
super(storageManager, name);
|
||||
this.containingDeclaration = containingDeclaration;
|
||||
this.source = source;
|
||||
this.isExternal = isExternal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isExternal() {
|
||||
return isExternal;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -47,9 +47,10 @@ public class ClassDescriptorImpl extends ClassDescriptorBase {
|
||||
@NotNull Modality modality,
|
||||
@NotNull ClassKind kind,
|
||||
@NotNull Collection<KotlinType> supertypes,
|
||||
@NotNull SourceElement source
|
||||
@NotNull SourceElement source,
|
||||
boolean isExternal
|
||||
) {
|
||||
super(LockBasedStorageManager.NO_LOCKS, containingDeclaration, name, source);
|
||||
super(LockBasedStorageManager.NO_LOCKS, containingDeclaration, name, source, isExternal);
|
||||
this.modality = modality;
|
||||
this.kind = kind;
|
||||
|
||||
|
||||
+1
-1
@@ -75,7 +75,7 @@ public class EnumEntrySyntheticClassDescriptor extends ClassDescriptorBase {
|
||||
@NotNull Annotations annotations,
|
||||
@NotNull SourceElement source
|
||||
) {
|
||||
super(storageManager, containingClass, name, source);
|
||||
super(storageManager, containingClass, name, source, /* isExternal = */ false);
|
||||
assert containingClass.getKind() == ClassKind.ENUM_CLASS;
|
||||
|
||||
this.annotations = annotations;
|
||||
|
||||
+5
@@ -216,6 +216,11 @@ public class LazySubstitutingClassDescriptor implements ClassDescriptor {
|
||||
return original.isData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isExternal() {
|
||||
return original.isExternal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCompanionObject() {
|
||||
return original.isCompanionObject();
|
||||
|
||||
+14
-4
@@ -46,6 +46,7 @@ public class PropertyDescriptorImpl extends VariableDescriptorWithInitializerImp
|
||||
private final boolean isConst;
|
||||
private final boolean isPlatform;
|
||||
private final boolean isImpl;
|
||||
private final boolean isExternal;
|
||||
|
||||
private ReceiverParameterDescriptor dispatchReceiverParameter;
|
||||
private ReceiverParameterDescriptor extensionReceiverParameter;
|
||||
@@ -67,7 +68,8 @@ public class PropertyDescriptorImpl extends VariableDescriptorWithInitializerImp
|
||||
boolean lateInit,
|
||||
boolean isConst,
|
||||
boolean isPlatform,
|
||||
boolean isImpl
|
||||
boolean isImpl,
|
||||
boolean isExternal
|
||||
) {
|
||||
super(containingDeclaration, annotations, name, null, isVar, source);
|
||||
this.modality = modality;
|
||||
@@ -78,6 +80,7 @@ public class PropertyDescriptorImpl extends VariableDescriptorWithInitializerImp
|
||||
this.isConst = isConst;
|
||||
this.isPlatform = isPlatform;
|
||||
this.isImpl = isImpl;
|
||||
this.isExternal = isExternal;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -93,10 +96,12 @@ public class PropertyDescriptorImpl extends VariableDescriptorWithInitializerImp
|
||||
boolean lateInit,
|
||||
boolean isConst,
|
||||
boolean isPlatform,
|
||||
boolean isImpl
|
||||
boolean isImpl,
|
||||
boolean isExternal
|
||||
) {
|
||||
return new PropertyDescriptorImpl(containingDeclaration, null, annotations,
|
||||
modality, visibility, isVar, name, kind, source, lateInit, isConst, isPlatform, isImpl);
|
||||
modality, visibility, isVar, name, kind, source, lateInit, isConst,
|
||||
isPlatform, isImpl, isExternal);
|
||||
}
|
||||
|
||||
public void setType(
|
||||
@@ -199,6 +204,11 @@ public class PropertyDescriptorImpl extends VariableDescriptorWithInitializerImp
|
||||
return isConst;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isExternal() {
|
||||
return isExternal;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public List<PropertyAccessorDescriptor> getAccessors() {
|
||||
@@ -342,7 +352,7 @@ public class PropertyDescriptorImpl extends VariableDescriptorWithInitializerImp
|
||||
) {
|
||||
return new PropertyDescriptorImpl(
|
||||
newOwner, original, getAnnotations(), newModality, newVisibility, isVar(), getName(), kind, SourceElement.NO_SOURCE,
|
||||
isLateInit(), isConst(), isPlatform(), isImpl()
|
||||
isLateInit(), isConst(), isPlatform(), isImpl(), isExternal()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -286,7 +286,9 @@ public class ErrorUtils {
|
||||
private static class ErrorClassDescriptor extends ClassDescriptorImpl {
|
||||
public ErrorClassDescriptor(@Nullable String name) {
|
||||
super(getErrorModule(), Name.special(name == null ? "<ERROR CLASS>" : "<ERROR CLASS: " + name + ">"),
|
||||
Modality.OPEN, ClassKind.CLASS, Collections.<KotlinType>emptyList(), SourceElement.NO_SOURCE);
|
||||
Modality.OPEN, ClassKind.CLASS, Collections.<KotlinType>emptyList(), SourceElement.NO_SOURCE,
|
||||
/* isExternal = */ false
|
||||
);
|
||||
|
||||
ClassConstructorDescriptorImpl
|
||||
errorConstructor = ClassConstructorDescriptorImpl.create(this, Annotations.Companion.getEMPTY(), true, SourceElement.NO_SOURCE);
|
||||
@@ -367,7 +369,8 @@ public class ErrorUtils {
|
||||
/* lateInit = */ false,
|
||||
/* isConst = */ false,
|
||||
/* isPlatform = */ false,
|
||||
/* isImpl = */ false
|
||||
/* isImpl = */ false,
|
||||
/* isExternal = */ false
|
||||
);
|
||||
descriptor.setType(ERROR_PROPERTY_TYPE,
|
||||
Collections.<TypeParameterDescriptor>emptyList(),
|
||||
|
||||
@@ -35,6 +35,7 @@ public class Flags {
|
||||
public static final FlagField<ProtoBuf.Class.Kind> CLASS_KIND = FlagField.after(MODALITY, ProtoBuf.Class.Kind.values());
|
||||
public static final BooleanFlagField IS_INNER = FlagField.booleanAfter(CLASS_KIND);
|
||||
public static final BooleanFlagField IS_DATA = FlagField.booleanAfter(IS_INNER);
|
||||
public static final BooleanFlagField IS_EXTERNAL_CLASS = FlagField.booleanAfter(IS_DATA);
|
||||
|
||||
// Constructors
|
||||
|
||||
@@ -61,6 +62,7 @@ public class Flags {
|
||||
public static final BooleanFlagField IS_CONST = FlagField.booleanAfter(HAS_SETTER);
|
||||
public static final BooleanFlagField IS_LATEINIT = FlagField.booleanAfter(IS_CONST);
|
||||
public static final BooleanFlagField HAS_CONSTANT = FlagField.booleanAfter(IS_LATEINIT);
|
||||
public static final BooleanFlagField IS_EXTERNAL_PROPERTY = FlagField.booleanAfter(HAS_CONSTANT);
|
||||
|
||||
// Parameters
|
||||
|
||||
|
||||
+1
@@ -46,6 +46,7 @@ class MemberDeserializer(private val c: DeserializationContext) {
|
||||
Deserialization.memberKind(Flags.MEMBER_KIND.get(flags)),
|
||||
Flags.IS_LATEINIT.get(flags),
|
||||
Flags.IS_CONST.get(flags),
|
||||
Flags.IS_EXTERNAL_PROPERTY.get(flags),
|
||||
proto,
|
||||
c.nameResolver,
|
||||
c.typeTable,
|
||||
|
||||
+2
-1
@@ -86,7 +86,7 @@ class NotFoundClasses(private val storageManager: StorageManager, private val mo
|
||||
name: Name,
|
||||
private val isInner: Boolean,
|
||||
numberOfDeclaredTypeParameters: Int
|
||||
) : ClassDescriptorBase(storageManager, container, name, SourceElement.NO_SOURCE) {
|
||||
) : ClassDescriptorBase(storageManager, container, name, SourceElement.NO_SOURCE, /* isExternal = */ false) {
|
||||
private val typeParameters = createTypeParameters(this, numberOfDeclaredTypeParameters)
|
||||
|
||||
private val typeConstructor = ClassTypeConstructorImpl(this, /* isFinal = */ true, typeParameters, setOf(module.builtIns.anyType))
|
||||
@@ -102,6 +102,7 @@ class NotFoundClasses(private val storageManager: StorageManager, private val mo
|
||||
override fun isData() = false
|
||||
override fun isPlatform() = false
|
||||
override fun isImpl() = false
|
||||
override fun isExternal() = false
|
||||
override val annotations: Annotations get() = Annotations.EMPTY
|
||||
|
||||
override fun getUnsubstitutedMemberScope() = MemberScope.Empty
|
||||
|
||||
+2
@@ -99,6 +99,8 @@ class DeserializedClassDescriptor(
|
||||
|
||||
override fun isImpl() = false
|
||||
|
||||
override fun isExternal() = Flags.IS_EXTERNAL_CLASS.get(classProto.flags)
|
||||
|
||||
override fun getUnsubstitutedMemberScope(): MemberScope = memberScope
|
||||
|
||||
override fun getStaticScope() = staticScope
|
||||
|
||||
+7
-2
@@ -21,6 +21,7 @@ import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
import org.jetbrains.kotlin.descriptors.impl.*
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.protobuf.MessageLite
|
||||
import org.jetbrains.kotlin.serialization.Flags
|
||||
import org.jetbrains.kotlin.serialization.ProtoBuf
|
||||
import org.jetbrains.kotlin.serialization.deserialization.NameResolver
|
||||
import org.jetbrains.kotlin.serialization.deserialization.TypeTable
|
||||
@@ -87,13 +88,15 @@ class DeserializedPropertyDescriptor(
|
||||
kind: CallableMemberDescriptor.Kind,
|
||||
isLateInit: Boolean,
|
||||
isConst: Boolean,
|
||||
isExternal: Boolean,
|
||||
override val proto: ProtoBuf.Property,
|
||||
override val nameResolver: NameResolver,
|
||||
override val typeTable: TypeTable,
|
||||
override val containerSource: DeserializedContainerSource?
|
||||
) : DeserializedCallableMemberDescriptor,
|
||||
PropertyDescriptorImpl(containingDeclaration, original, annotations,
|
||||
modality, visibility, isVar, name, kind, SourceElement.NO_SOURCE, isLateInit, isConst, false, false) {
|
||||
modality, visibility, isVar, name, kind, SourceElement.NO_SOURCE, isLateInit, isConst, false, false,
|
||||
isExternal) {
|
||||
|
||||
override fun createSubstitutedCopy(
|
||||
newOwner: DeclarationDescriptor,
|
||||
@@ -103,10 +106,12 @@ class DeserializedPropertyDescriptor(
|
||||
kind: CallableMemberDescriptor.Kind
|
||||
): PropertyDescriptorImpl {
|
||||
return DeserializedPropertyDescriptor(
|
||||
newOwner, original, annotations, newModality, newVisibility, isVar, name, kind, isLateInit, isConst,
|
||||
newOwner, original, annotations, newModality, newVisibility, isVar, name, kind, isLateInit, isConst, isExternal,
|
||||
proto, nameResolver, typeTable, containerSource
|
||||
)
|
||||
}
|
||||
|
||||
override fun isExternal() = Flags.IS_EXTERNAL_PROPERTY.get(proto.flags)
|
||||
}
|
||||
|
||||
class DeserializedClassConstructorDescriptor(
|
||||
|
||||
Reference in New Issue
Block a user