Add external property to class and property descriptors
This commit is contained in:
+1
-1
@@ -78,7 +78,7 @@ public class AccessorForPropertyDescriptor extends PropertyDescriptorImpl implem
|
||||
super(containingDeclaration, null, Annotations.Companion.getEMPTY(), Modality.FINAL, Visibilities.LOCAL,
|
||||
original.isVar(), Name.identifier("access$" + nameSuffix),
|
||||
Kind.DECLARATION, SourceElement.NO_SOURCE, /* lateInit = */ false, /* isConst = */ false,
|
||||
/* isPlatform = */ false, /* isImpl = */ false);
|
||||
/* isPlatform = */ false, /* isImpl = */ false, /* isExternal = */ false);
|
||||
|
||||
this.calleeDescriptor = original;
|
||||
this.superCallTarget = superCallTarget;
|
||||
|
||||
@@ -308,8 +308,8 @@ class CollectionStubMethodGenerator(
|
||||
}
|
||||
|
||||
private fun createSyntheticSubclass(): Pair<MutableClassDescriptor, List<TypeParameterDescriptor>> {
|
||||
val child = MutableClassDescriptor(descriptor.containingDeclaration, ClassKind.CLASS, false,
|
||||
Name.special("<synthetic inheritor of ${descriptor.name}>"), descriptor.source)
|
||||
val child = MutableClassDescriptor(descriptor.containingDeclaration, ClassKind.CLASS, /* isInner = */ false,
|
||||
/* isExternal */ false, Name.special("<synthetic inheritor of ${descriptor.name}>"), descriptor.source)
|
||||
child.modality = Modality.FINAL
|
||||
child.visibility = Visibilities.PUBLIC
|
||||
val typeParameters = descriptor.typeConstructor.parameters
|
||||
|
||||
@@ -62,7 +62,8 @@ class InterfaceImplBodyCodegen(
|
||||
if (DescriptorUtils.isLocal(descriptor)) return null
|
||||
val classDescriptorImpl = ClassDescriptorImpl(
|
||||
descriptor, Name.identifier(JvmAbi.DEFAULT_IMPLS_CLASS_NAME),
|
||||
Modality.FINAL, ClassKind.CLASS, Collections.emptyList(), SourceElement.NO_SOURCE)
|
||||
Modality.FINAL, ClassKind.CLASS, Collections.emptyList(), SourceElement.NO_SOURCE,
|
||||
/* isExternal = */ false)
|
||||
|
||||
classDescriptorImpl.initialize(MemberScope.Empty, emptySet(), null)
|
||||
return classDescriptorImpl
|
||||
|
||||
@@ -67,7 +67,8 @@ class JvmRuntimeTypes(module: ModuleDescriptor) {
|
||||
}
|
||||
|
||||
private fun createClass(packageFragment: PackageFragmentDescriptor, name: String): ClassDescriptor =
|
||||
MutableClassDescriptor(packageFragment, ClassKind.CLASS, false, Name.identifier(name), SourceElement.NO_SOURCE).apply {
|
||||
MutableClassDescriptor(packageFragment, ClassKind.CLASS, /* isInner = */ false, /* isExternal = */ false,
|
||||
Name.identifier(name), SourceElement.NO_SOURCE).apply {
|
||||
modality = Modality.FINAL
|
||||
visibility = Visibilities.PUBLIC
|
||||
setTypeParameterDescriptors(emptyList())
|
||||
|
||||
@@ -47,10 +47,11 @@ public class MutableClassDescriptor extends ClassDescriptorBase implements Class
|
||||
@NotNull DeclarationDescriptor containingDeclaration,
|
||||
@NotNull ClassKind kind,
|
||||
boolean isInner,
|
||||
boolean isExternal,
|
||||
@NotNull Name name,
|
||||
@NotNull SourceElement source
|
||||
) {
|
||||
super(LockBasedStorageManager.NO_LOCKS, containingDeclaration, name, source);
|
||||
super(LockBasedStorageManager.NO_LOCKS, containingDeclaration, name, source, isExternal);
|
||||
assert kind != ClassKind.OBJECT : "Fix isCompanionObject()";
|
||||
|
||||
this.kind = kind;
|
||||
|
||||
@@ -84,7 +84,8 @@ public class SamWrapperCodegen {
|
||||
Modality.FINAL,
|
||||
ClassKind.CLASS,
|
||||
Collections.singleton(samType.getType()),
|
||||
SourceElement.NO_SOURCE
|
||||
SourceElement.NO_SOURCE,
|
||||
/* isExternal = */ false
|
||||
);
|
||||
// e.g. compare(T, T)
|
||||
SimpleFunctionDescriptor erasedInterfaceFunction = samType.getAbstractMethod().getOriginal().copy(
|
||||
|
||||
+2
-1
@@ -31,7 +31,8 @@ class SyntheticClassDescriptorForLambda(
|
||||
name: Name,
|
||||
supertypes: Collection<KotlinType>,
|
||||
element: KtElement
|
||||
) : ClassDescriptorImpl(containingDeclaration, name, Modality.FINAL, ClassKind.CLASS, supertypes, element.toSourceElement()) {
|
||||
) : ClassDescriptorImpl(containingDeclaration, name, Modality.FINAL, ClassKind.CLASS, supertypes, element.toSourceElement(),
|
||||
/* isExternal = */ false) {
|
||||
init {
|
||||
initialize(MemberScope.Empty, emptySet(), null)
|
||||
}
|
||||
|
||||
+1
-1
@@ -280,7 +280,7 @@ class JavaSyntheticPropertiesScope(storageManager: StorageManager, private val l
|
||||
source: SourceElement
|
||||
) : SyntheticJavaPropertyDescriptor, PropertyDescriptorImpl(
|
||||
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
|
||||
) {
|
||||
|
||||
override var getMethod: FunctionDescriptor by Delegates.notNull()
|
||||
|
||||
@@ -811,7 +811,8 @@ public class DescriptorResolver {
|
||||
modifierList != null && modifierList.hasModifier(KtTokens.CONST_KEYWORD),
|
||||
modifierList != null && modifierList.hasModifier(KtTokens.PLATFORM_KEYWORD) ||
|
||||
containingDeclaration instanceof ClassDescriptor && ((ClassDescriptor) containingDeclaration).isPlatform(),
|
||||
modifierList != null && modifierList.hasModifier(KtTokens.IMPL_KEYWORD)
|
||||
modifierList != null && modifierList.hasModifier(KtTokens.IMPL_KEYWORD),
|
||||
modifierList != null && modifierList.hasModifier(KtTokens.EXTERNAL_KEYWORD)
|
||||
);
|
||||
wrapper.setDescriptor(propertyDescriptor);
|
||||
|
||||
@@ -1128,7 +1129,8 @@ public class DescriptorResolver {
|
||||
/* lateInit = */ false,
|
||||
/* isConst = */ false,
|
||||
/* isPlatform = */ false,
|
||||
/* isImpl = */ false
|
||||
/* isImpl = */ false,
|
||||
/* isExternal = */ false
|
||||
);
|
||||
propertyWrapper.setDescriptor(propertyDescriptor);
|
||||
propertyDescriptor.setType(type, Collections.<TypeParameterDescriptor>emptyList(),
|
||||
|
||||
@@ -148,7 +148,8 @@ class LocalVariableResolver(
|
||||
/* lateInit = */ false,
|
||||
/* isConst = */ false,
|
||||
/* isPlatform = */ false,
|
||||
/* isImpl = */ false
|
||||
/* isImpl = */ false,
|
||||
/* isExternal = */ false
|
||||
)
|
||||
// For a local variable the type must not be deferred
|
||||
type = variableTypeAndInitializerResolver.resolveType(propertyDescriptor, scope, variable, dataFlowInfo, trace, local = true)
|
||||
|
||||
@@ -99,7 +99,8 @@ class DynamicCallableDescriptors(storageManager: StorageManager, builtIns: Kotli
|
||||
/* lateInit = */ false,
|
||||
/* isConst = */ false,
|
||||
/* isPlatform = */ false,
|
||||
/* isImpl = */ false
|
||||
/* isImpl = */ false,
|
||||
/* isExternal = */ false
|
||||
)
|
||||
propertyDescriptor.setType(
|
||||
dynamicType,
|
||||
|
||||
+5
-2
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.resolve.lazy.descriptors
|
||||
import com.google.common.collect.Sets
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.incremental.components.LookupLocation
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.resolve.BindingTrace
|
||||
@@ -53,8 +54,10 @@ protected constructor(
|
||||
return declarationProvider.getClassOrObjectDeclarations(name).map {
|
||||
if (it is KtScriptInfo)
|
||||
LazyScriptDescriptor(c as ResolveSession, thisDescriptor, name, it)
|
||||
else
|
||||
LazyClassDescriptor(c, thisDescriptor, name, it)
|
||||
else {
|
||||
val isExternal = it.modifierList?.hasModifier(KtTokens.EXTERNAL_KEYWORD) ?: false
|
||||
LazyClassDescriptor(c, thisDescriptor, name, it, isExternal)
|
||||
}
|
||||
}.toReadOnlyList()
|
||||
}
|
||||
|
||||
|
||||
+4
-2
@@ -111,10 +111,12 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
||||
@NotNull final LazyClassContext c,
|
||||
@NotNull DeclarationDescriptor containingDeclaration,
|
||||
@NotNull Name name,
|
||||
@NotNull final KtClassLikeInfo classLikeInfo
|
||||
@NotNull final KtClassLikeInfo classLikeInfo,
|
||||
boolean isExternal
|
||||
) {
|
||||
super(c.getStorageManager(), containingDeclaration, name,
|
||||
KotlinSourceElementKt.toSourceElement(classLikeInfo.getCorrespondingClassOrObject())
|
||||
KotlinSourceElementKt.toSourceElement(classLikeInfo.getCorrespondingClassOrObject()),
|
||||
isExternal
|
||||
);
|
||||
this.c = c;
|
||||
|
||||
|
||||
+2
-1
@@ -43,7 +43,8 @@ class LazyScriptDescriptor(
|
||||
resolveSession,
|
||||
containingDeclaration,
|
||||
name,
|
||||
scriptInfo
|
||||
scriptInfo,
|
||||
/* isExternal = */ false
|
||||
) {
|
||||
init {
|
||||
resolveSession.trace.record(BindingContext.SCRIPT, scriptInfo.script, this)
|
||||
|
||||
+3
-1
@@ -30,6 +30,7 @@ import org.jetbrains.kotlin.descriptors.SupertypeLoopChecker
|
||||
import org.jetbrains.kotlin.frontend.di.createContainerForLazyLocalClassifierAnalyzer
|
||||
import org.jetbrains.kotlin.incremental.components.LookupLocation
|
||||
import org.jetbrains.kotlin.incremental.components.LookupTracker
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.psi.KtClassOrObject
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
@@ -152,7 +153,8 @@ class LocalClassDescriptorHolder(
|
||||
,
|
||||
containingDeclaration,
|
||||
classOrObject.getNameAsSafeName(),
|
||||
KtClassInfoUtil.createClassLikeInfo(classOrObject)
|
||||
KtClassInfoUtil.createClassLikeInfo(classOrObject),
|
||||
classOrObject.hasModifier(KtTokens.EXTERNAL_KEYWORD)
|
||||
)
|
||||
writableScope?.addClassifierDescriptor(classDescriptor!!)
|
||||
}
|
||||
|
||||
+2
@@ -33,4 +33,6 @@ class DefaultImplsClassDescriptorImpl(
|
||||
init {
|
||||
initialize(emptyList(), listOf(correspondingInterface.module.builtIns.anyType))
|
||||
}
|
||||
|
||||
override fun isExternal() = false
|
||||
}
|
||||
+2
@@ -37,4 +37,6 @@ class FileClassDescriptorImpl(
|
||||
init {
|
||||
initialize(emptyList(), supertypes)
|
||||
}
|
||||
|
||||
override fun isExternal() = false
|
||||
}
|
||||
+1
-1
@@ -44,7 +44,7 @@ class JvmPropertyDescriptorImpl(
|
||||
isImpl: Boolean
|
||||
) : JvmDescriptorWithExtraFlags, PropertyDescriptorImpl(
|
||||
containingDeclaration, original, annotations, modality, visibility, isVar,
|
||||
name, kind, source, isLateInit, isConst, isPlatform, isImpl
|
||||
name, kind, source, isLateInit, isConst, isPlatform, isImpl, /* isExternal = */ false
|
||||
) {
|
||||
override fun createSubstitutedCopy(
|
||||
newOwner: DeclarationDescriptor,
|
||||
|
||||
+1
@@ -140,6 +140,7 @@ open class KnownClassDescriptor(
|
||||
override fun isInner(): Boolean = false
|
||||
override fun isPlatform(): Boolean = false
|
||||
override fun isImpl(): Boolean = false
|
||||
override fun isExternal(): Boolean = false
|
||||
|
||||
override fun <R : Any?, D : Any?> accept(visitor: DeclarationDescriptorVisitor<R, D>, data: D): R {
|
||||
return visitor.visitClassDescriptor(this, data)
|
||||
|
||||
+4
-2
@@ -59,7 +59,8 @@ class JvmSharedVariablesManager(val builtIns: KotlinBuiltIns) : SharedVariablesM
|
||||
PropertyDescriptorImpl.create(
|
||||
refClass, Annotations.EMPTY, Modality.FINAL, Visibilities.PUBLIC, true,
|
||||
Name.identifier("element"), CallableMemberDescriptor.Kind.DECLARATION, SourceElement.NO_SOURCE,
|
||||
false, false, false, false
|
||||
/* lateInit = */ false, /* isConst = */ false, /* isPlatform = */ false, /* isImpl = */ false,
|
||||
/* isExternal = */ false
|
||||
).initialize(type, dispatchReceiverParameter = refClass.thisAsReceiverParameter)
|
||||
}
|
||||
|
||||
@@ -99,7 +100,8 @@ class JvmSharedVariablesManager(val builtIns: KotlinBuiltIns) : SharedVariablesM
|
||||
PropertyDescriptorImpl.create(
|
||||
genericRefClass, Annotations.EMPTY, Modality.FINAL, Visibilities.PUBLIC, true,
|
||||
Name.identifier("element"), CallableMemberDescriptor.Kind.DECLARATION, SourceElement.NO_SOURCE,
|
||||
false, false, false, false
|
||||
/* lateInit = */ false, /* isConst = */ false, /* isPlatform = */ false, /* isImpl = */ false,
|
||||
/* isExternal = */ false
|
||||
).initialize(
|
||||
type = builtIns.anyType,
|
||||
dispatchReceiverParameter = genericRefClass.thisAsReceiverParameter
|
||||
|
||||
+2
-1
@@ -128,7 +128,8 @@ class SpecialDescriptorsFactory(
|
||||
objectDescriptor,
|
||||
Annotations.EMPTY, Modality.FINAL, Visibilities.PUBLIC, false,
|
||||
Name.identifier("INSTANCE"),
|
||||
CallableMemberDescriptor.Kind.SYNTHESIZED, SourceElement.NO_SOURCE, false, false, false, false
|
||||
CallableMemberDescriptor.Kind.SYNTHESIZED, SourceElement.NO_SOURCE, /* lateInit = */ false, /* isConst = */ false,
|
||||
/* isPlatform = */ false, /* isImpl = */ false, /* isExternal = */ false
|
||||
).initialize(objectDescriptor.defaultType)
|
||||
|
||||
return instanceFieldDescriptor
|
||||
|
||||
@@ -61,7 +61,8 @@ abstract class IrDelegateDescriptorBase(
|
||||
/* lateInit = */ false,
|
||||
/* isConst = */ false,
|
||||
/* isPlatform = */ false,
|
||||
/* isImpl = */ false
|
||||
/* isImpl = */ false,
|
||||
/* isExternal = */ false
|
||||
) {
|
||||
init {
|
||||
setOutType(delegateType)
|
||||
|
||||
Reference in New Issue
Block a user