Introduce PropertyDescriptor.isDelegated, write new flag to metadata
#KT-8384 In Progress
This commit is contained in:
+2
-3
@@ -76,9 +76,8 @@ public class AccessorForPropertyDescriptor extends PropertyDescriptorImpl implem
|
||||
boolean setterAccessorRequired
|
||||
) {
|
||||
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,
|
||||
/* isHeader = */ false, /* isImpl = */ false, /* isExternal = */ false);
|
||||
original.isVar(), Name.identifier("access$" + nameSuffix), Kind.DECLARATION, SourceElement.NO_SOURCE,
|
||||
false, false, false, false, false, false);
|
||||
|
||||
this.calleeDescriptor = original;
|
||||
this.superCallTarget = superCallTarget;
|
||||
|
||||
+2
-1
@@ -280,7 +280,8 @@ class JavaSyntheticPropertiesScope(storageManager: StorageManager, private val l
|
||||
source: SourceElement
|
||||
) : SyntheticJavaPropertyDescriptor, PropertyDescriptorImpl(
|
||||
containingDeclaration, original, annotations, modality, visibility, isVar, name, kind, source,
|
||||
/* lateInit = */ false, /* isConst = */ false, /* isHeader = */ false, /* isImpl = */ false, /* isExternal = */ false
|
||||
/* lateInit = */ false, /* isConst = */ false, /* isHeader = */ false, /* isImpl = */ false, /* isExternal = */ false,
|
||||
/* isDelegated = */ false
|
||||
) {
|
||||
|
||||
override var getMethod: FunctionDescriptor by Delegates.notNull()
|
||||
|
||||
+3
@@ -83,6 +83,9 @@ public class LocalVariableDescriptor extends VariableDescriptorWithInitializerIm
|
||||
return setter;
|
||||
}
|
||||
|
||||
// This override is not deprecated because local variables can only come from sources,
|
||||
// and we can be sure that they won't be recompiled independently
|
||||
@Override
|
||||
public boolean isDelegated() {
|
||||
return isDelegated;
|
||||
}
|
||||
|
||||
@@ -833,7 +833,8 @@ public class DescriptorResolver {
|
||||
modifierList != null && modifierList.hasModifier(KtTokens.HEADER_KEYWORD) ||
|
||||
containingDeclaration instanceof ClassDescriptor && ((ClassDescriptor) containingDeclaration).isHeader(),
|
||||
modifierList != null && modifierList.hasModifier(KtTokens.IMPL_KEYWORD),
|
||||
modifierList != null && modifierList.hasModifier(KtTokens.EXTERNAL_KEYWORD)
|
||||
modifierList != null && modifierList.hasModifier(KtTokens.EXTERNAL_KEYWORD),
|
||||
property.hasDelegate()
|
||||
);
|
||||
wrapper.setDescriptor(propertyDescriptor);
|
||||
|
||||
@@ -1161,11 +1162,12 @@ public class DescriptorResolver {
|
||||
name,
|
||||
CallableMemberDescriptor.Kind.DECLARATION,
|
||||
KotlinSourceElementKt.toSourceElement(parameter),
|
||||
/* lateInit = */ false,
|
||||
/* isConst = */ false,
|
||||
/* isHeader = */ classDescriptor.isHeader(),
|
||||
/* isImpl = */ modifierList != null && modifierList.hasModifier(KtTokens.IMPL_KEYWORD),
|
||||
/* isExternal = */ false
|
||||
false,
|
||||
false,
|
||||
classDescriptor.isHeader(),
|
||||
modifierList != null && modifierList.hasModifier(KtTokens.IMPL_KEYWORD),
|
||||
false,
|
||||
false
|
||||
);
|
||||
propertyWrapper.setDescriptor(propertyDescriptor);
|
||||
propertyDescriptor.setType(type, Collections.<TypeParameterDescriptor>emptyList(),
|
||||
|
||||
@@ -148,7 +148,8 @@ class LocalVariableResolver(
|
||||
/* isConst = */ false,
|
||||
/* isHeader = */ false,
|
||||
/* isImpl = */ false,
|
||||
/* isExternal = */ false
|
||||
/* isExternal = */ false,
|
||||
variable is KtProperty && variable.hasDelegate()
|
||||
)
|
||||
// For a local variable the type must not be deferred
|
||||
type = variableTypeAndInitializerResolver.resolveType(propertyDescriptor, scope, variable, dataFlowInfo, trace, local = true)
|
||||
|
||||
@@ -100,7 +100,8 @@ class DynamicCallableDescriptors(storageManager: StorageManager, builtIns: Kotli
|
||||
/* isConst = */ false,
|
||||
/* isHeader = */ false,
|
||||
/* isImpl = */ false,
|
||||
/* isExternal = */ false
|
||||
/* isExternal = */ false,
|
||||
/* isDelegated = */ false
|
||||
)
|
||||
propertyDescriptor.setType(
|
||||
dynamicType,
|
||||
@@ -230,4 +231,3 @@ fun DeclarationDescriptor.isDynamic(): Boolean {
|
||||
val dispatchReceiverParameter = dispatchReceiverParameter
|
||||
return dispatchReceiverParameter != null && dispatchReceiverParameter.type.isDynamic()
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -27,7 +27,7 @@ interface JvmDescriptorWithExtraFlags {
|
||||
val extraFlags: Int
|
||||
}
|
||||
|
||||
class JvmPropertyDescriptorImpl(
|
||||
class JvmPropertyDescriptorImpl private constructor(
|
||||
containingDeclaration: DeclarationDescriptor,
|
||||
original: PropertyDescriptor?,
|
||||
annotations: Annotations,
|
||||
@@ -44,7 +44,7 @@ class JvmPropertyDescriptorImpl(
|
||||
isImpl: Boolean
|
||||
) : JvmDescriptorWithExtraFlags, PropertyDescriptorImpl(
|
||||
containingDeclaration, original, annotations, modality, visibility, isVar,
|
||||
name, kind, source, isLateInit, isConst, isHeader, isImpl, /* isExternal = */ false
|
||||
name, kind, source, isLateInit, isConst, isHeader, isImpl, /* isExternal = */ false, false
|
||||
) {
|
||||
override fun createSubstitutedCopy(
|
||||
newOwner: DeclarationDescriptor,
|
||||
|
||||
+2
-2
@@ -54,7 +54,7 @@ class JvmSharedVariablesManager(val builtIns: KotlinBuiltIns) : SharedVariablesM
|
||||
refClass, Annotations.EMPTY, Modality.FINAL, Visibilities.PUBLIC, true,
|
||||
Name.identifier("element"), CallableMemberDescriptor.Kind.DECLARATION, SourceElement.NO_SOURCE,
|
||||
/* lateInit = */ false, /* isConst = */ false, /* isHeader = */ false, /* isImpl = */ false,
|
||||
/* isExternal = */ false
|
||||
/* isExternal = */ false, /* isDelegated = */ false
|
||||
).initialize(type, dispatchReceiverParameter = refClass.thisAsReceiverParameter)
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ class JvmSharedVariablesManager(val builtIns: KotlinBuiltIns) : SharedVariablesM
|
||||
genericRefClass, Annotations.EMPTY, Modality.FINAL, Visibilities.PUBLIC, true,
|
||||
Name.identifier("element"), CallableMemberDescriptor.Kind.DECLARATION, SourceElement.NO_SOURCE,
|
||||
/* lateInit = */ false, /* isConst = */ false, /* isHeader = */ false, /* isImpl = */ false,
|
||||
/* isExternal = */ false
|
||||
/* isExternal = */ false, /* isDelegated = */ false
|
||||
).initialize(
|
||||
type = builtIns.anyType,
|
||||
dispatchReceiverParameter = genericRefClass.thisAsReceiverParameter
|
||||
|
||||
+2
-2
@@ -129,9 +129,9 @@ class SpecialDescriptorsFactory(
|
||||
Annotations.EMPTY, Modality.FINAL, Visibilities.PUBLIC, false,
|
||||
Name.identifier("INSTANCE"),
|
||||
CallableMemberDescriptor.Kind.SYNTHESIZED, SourceElement.NO_SOURCE, /* lateInit = */ false, /* isConst = */ false,
|
||||
/* isHeader = */ false, /* isImpl = */ false, /* isExternal = */ false
|
||||
/* isHeader = */ false, /* isImpl = */ false, /* isExternal = */ false, /* isDelegated = */ false
|
||||
).initialize(objectDescriptor.defaultType)
|
||||
|
||||
return instanceFieldDescriptor
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -116,6 +116,7 @@ class AssignmentGenerator(statementGenerator: StatementGenerator) : StatementGen
|
||||
|
||||
}
|
||||
is LocalVariableDescriptor ->
|
||||
@Suppress("DEPRECATION")
|
||||
if (descriptor.isDelegated)
|
||||
DelegatedLocalPropertyLValue(ktLeft.startOffset, ktLeft.endOffset, descriptor, origin)
|
||||
else
|
||||
|
||||
@@ -18,7 +18,9 @@ package org.jetbrains.kotlin.psi2ir.generators
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.impl.LocalVariableDescriptor
|
||||
import org.jetbrains.kotlin.ir.expressions.*
|
||||
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
||||
import org.jetbrains.kotlin.ir.expressions.IrMemberAccessExpression
|
||||
import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.*
|
||||
import org.jetbrains.kotlin.psi.KtElement
|
||||
import org.jetbrains.kotlin.psi.psiUtil.endOffset
|
||||
@@ -51,6 +53,7 @@ class CallGenerator(statementGenerator: StatementGenerator): StatementGeneratorE
|
||||
descriptor: VariableDescriptor,
|
||||
typeArguments: Map<TypeParameterDescriptor, KotlinType>?,
|
||||
origin: IrStatementOrigin? = null) =
|
||||
@Suppress("DEPRECATION")
|
||||
if (descriptor is LocalVariableDescriptor && descriptor.isDelegated)
|
||||
IrCallImpl(startOffset, endOffset, descriptor.type, descriptor.getter!!, typeArguments, origin ?: IrStatementOrigin.GET_LOCAL_PROPERTY)
|
||||
else
|
||||
|
||||
@@ -62,7 +62,8 @@ abstract class IrDelegateDescriptorBase(
|
||||
/* isConst = */ false,
|
||||
/* isHeader = */ false,
|
||||
/* isImpl = */ false,
|
||||
/* isExternal = */ false
|
||||
/* isExternal = */ false,
|
||||
/* isDelegated = */ true
|
||||
) {
|
||||
init {
|
||||
setOutType(delegateType)
|
||||
@@ -134,4 +135,4 @@ class IrLocalDelegatedPropertyDelegateDescriptorImpl(
|
||||
|
||||
override fun <R : Any?, D : Any?> accept(visitor: DeclarationDescriptorVisitor<R, D>, data: D): R =
|
||||
visitor.visitVariableDescriptor(this, data)
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -188,7 +188,8 @@ class DescriptorSerializer private constructor(
|
||||
|
||||
val flags = Flags.getPropertyFlags(
|
||||
hasAnnotations, descriptor.visibility, descriptor.modality, descriptor.kind, descriptor.isVar,
|
||||
hasGetter, hasSetter, hasConstant, isConst, lateInit, descriptor.isExternal
|
||||
hasGetter, hasSetter, hasConstant, isConst, lateInit, descriptor.isExternal,
|
||||
@Suppress("DEPRECATION") descriptor.isDelegated
|
||||
)
|
||||
if (flags != builder.flags) {
|
||||
builder.flags = flags
|
||||
|
||||
Reference in New Issue
Block a user