Revert "[FE 1.0] Provide an API to clean compile time initializer cache for variable descriptor"
This reverts commit 0e6762acc3.
This commit is contained in:
committed by
TeamCityServer
parent
965bab2d2d
commit
faeb5d21ab
@@ -410,8 +410,6 @@ class TypeResolver(
|
|||||||
|
|
||||||
override fun getCompileTimeInitializer() = null
|
override fun getCompileTimeInitializer() = null
|
||||||
|
|
||||||
override fun cleanCompileTimeInitializerCache() {}
|
|
||||||
|
|
||||||
override fun <R : Any?, D : Any?> accept(visitor: DeclarationDescriptorVisitor<R, D>, data: D): R {
|
override fun <R : Any?, D : Any?> accept(visitor: DeclarationDescriptorVisitor<R, D>, data: D): R {
|
||||||
return visitor.visitVariableDescriptor(this, data)
|
return visitor.visitVariableDescriptor(this, data)
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-5
@@ -114,9 +114,9 @@ class VariableTypeAndInitializerResolver(
|
|||||||
trace: BindingTrace
|
trace: BindingTrace
|
||||||
) {
|
) {
|
||||||
if (!variable.hasInitializer() || variable.isVar) return
|
if (!variable.hasInitializer() || variable.isVar) return
|
||||||
variableDescriptor.setCompileTimeInitializerFactory {
|
variableDescriptor.setCompileTimeInitializer(
|
||||||
storageManager.createRecursionTolerantNullableLazyValue(
|
storageManager.createRecursionTolerantNullableLazyValue(
|
||||||
computeInitializer@{
|
computeInitializer@ {
|
||||||
if (!DescriptorUtils.shouldRecordInitializerForProperty(
|
if (!DescriptorUtils.shouldRecordInitializerForProperty(
|
||||||
variableDescriptor,
|
variableDescriptor,
|
||||||
variableType
|
variableType
|
||||||
@@ -133,17 +133,18 @@ class VariableTypeAndInitializerResolver(
|
|||||||
constantExpressionEvaluator.module
|
constantExpressionEvaluator.module
|
||||||
)
|
)
|
||||||
val constant = constantExpressionEvaluator.evaluateExpression(initializer, trace, initializerType)
|
val constant = constantExpressionEvaluator.evaluateExpression(initializer, trace, initializerType)
|
||||||
?: return@computeInitializer null
|
?: return@computeInitializer null
|
||||||
|
|
||||||
if (constant.usesNonConstValAsConstant && variableDescriptor.isConst) {
|
if (constant.usesNonConstValAsConstant && variableDescriptor.isConst) {
|
||||||
trace.report(Errors.NON_CONST_VAL_USED_IN_CONSTANT_EXPRESSION.on(initializer))
|
trace.report(Errors.NON_CONST_VAL_USED_IN_CONSTANT_EXPRESSION.on(initializer))
|
||||||
}
|
}
|
||||||
|
|
||||||
constant.toConstantValue(initializerType)
|
val qqq = constant.toConstantValue(initializerType)
|
||||||
|
qqq
|
||||||
},
|
},
|
||||||
null
|
null
|
||||||
)
|
)
|
||||||
}
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun resolveDelegatedPropertyType(
|
private fun resolveDelegatedPropertyType(
|
||||||
|
|||||||
@@ -185,7 +185,6 @@ open class IrBasedValueParameterDescriptor(owner: IrValueParameter) : ValueParam
|
|||||||
override fun getName() = owner.name
|
override fun getName() = owner.name
|
||||||
override fun declaresDefaultValue() = owner.defaultValue != null
|
override fun declaresDefaultValue() = owner.defaultValue != null
|
||||||
override fun getCompileTimeInitializer(): ConstantValue<*>? = null
|
override fun getCompileTimeInitializer(): ConstantValue<*>? = null
|
||||||
override fun cleanCompileTimeInitializerCache() {}
|
|
||||||
|
|
||||||
override fun copy(newOwner: CallableDescriptor, newName: Name, newIndex: Int) = TODO("not implemented")
|
override fun copy(newOwner: CallableDescriptor, newName: Name, newIndex: Int) = TODO("not implemented")
|
||||||
|
|
||||||
@@ -326,8 +325,6 @@ open class IrBasedVariableDescriptor(owner: IrVariable) : VariableDescriptor, Ir
|
|||||||
TODO("")
|
TODO("")
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun cleanCompileTimeInitializerCache() {}
|
|
||||||
|
|
||||||
override fun getOverriddenDescriptors(): Collection<VariableDescriptor> {
|
override fun getOverriddenDescriptors(): Collection<VariableDescriptor> {
|
||||||
TODO("Not Implemented")
|
TODO("Not Implemented")
|
||||||
}
|
}
|
||||||
@@ -362,8 +359,6 @@ open class IrBasedVariableDescriptorWithAccessor(owner: IrLocalDelegatedProperty
|
|||||||
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun cleanCompileTimeInitializerCache() {}
|
|
||||||
|
|
||||||
override fun getType(): KotlinType = owner.type.toIrBasedKotlinType()
|
override fun getType(): KotlinType = owner.type.toIrBasedKotlinType()
|
||||||
|
|
||||||
override fun isConst(): Boolean = false
|
override fun isConst(): Boolean = false
|
||||||
@@ -833,8 +828,6 @@ open class IrBasedPropertyDescriptor(owner: IrProperty) :
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun cleanCompileTimeInitializerCache() {}
|
|
||||||
|
|
||||||
override fun isSetterProjectedOut(): Boolean {
|
override fun isSetterProjectedOut(): Boolean {
|
||||||
TODO("not implemented")
|
TODO("not implemented")
|
||||||
}
|
}
|
||||||
@@ -1023,8 +1016,6 @@ open class IrBasedFieldDescriptor(owner: IrField) : PropertyDescriptor, IrBasedD
|
|||||||
TODO("not implemented")
|
TODO("not implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun cleanCompileTimeInitializerCache() {}
|
|
||||||
|
|
||||||
override fun isSetterProjectedOut(): Boolean {
|
override fun isSetterProjectedOut(): Boolean {
|
||||||
TODO("not implemented")
|
TODO("not implemented")
|
||||||
}
|
}
|
||||||
|
|||||||
-1
@@ -119,7 +119,6 @@ class IrBuiltinValueParameterDescriptorImpl(
|
|||||||
override val isNoinline: Boolean get() = false
|
override val isNoinline: Boolean get() = false
|
||||||
override val varargElementType: KotlinType? get() = null
|
override val varargElementType: KotlinType? get() = null
|
||||||
override fun getCompileTimeInitializer(): ConstantValue<*>? = null
|
override fun getCompileTimeInitializer(): ConstantValue<*>? = null
|
||||||
override fun cleanCompileTimeInitializerCache() {}
|
|
||||||
override fun isVar(): Boolean = false
|
override fun isVar(): Boolean = false
|
||||||
override fun getVisibility(): DescriptorVisibility = DescriptorVisibilities.LOCAL
|
override fun getVisibility(): DescriptorVisibility = DescriptorVisibilities.LOCAL
|
||||||
|
|
||||||
|
|||||||
@@ -76,8 +76,6 @@ abstract class IrDelegateDescriptorBase(
|
|||||||
|
|
||||||
override fun getCompileTimeInitializer(): ConstantValue<*>? = null
|
override fun getCompileTimeInitializer(): ConstantValue<*>? = null
|
||||||
|
|
||||||
override fun cleanCompileTimeInitializerCache() {}
|
|
||||||
|
|
||||||
override fun getVisibility(): DescriptorVisibility = DescriptorVisibilities.PRIVATE
|
override fun getVisibility(): DescriptorVisibility = DescriptorVisibilities.PRIVATE
|
||||||
|
|
||||||
override fun substitute(substitutor: TypeSubstitutor): PropertyDescriptor {
|
override fun substitute(substitutor: TypeSubstitutor): PropertyDescriptor {
|
||||||
@@ -133,7 +131,6 @@ class IrLocalDelegatedPropertyDelegateDescriptorImpl(
|
|||||||
) {
|
) {
|
||||||
|
|
||||||
override fun getCompileTimeInitializer(): ConstantValue<*>? = null
|
override fun getCompileTimeInitializer(): ConstantValue<*>? = null
|
||||||
override fun cleanCompileTimeInitializerCache() {}
|
|
||||||
override fun isVar(): Boolean = false
|
override fun isVar(): Boolean = false
|
||||||
override fun isLateInit(): Boolean = false
|
override fun isLateInit(): Boolean = false
|
||||||
override fun substitute(substitutor: TypeSubstitutor): VariableDescriptor? = throw UnsupportedOperationException()
|
override fun substitute(substitutor: TypeSubstitutor): VariableDescriptor? = throw UnsupportedOperationException()
|
||||||
|
|||||||
-2
@@ -65,8 +65,6 @@ open class FakeCallableDescriptorForObject(
|
|||||||
|
|
||||||
override fun getCompileTimeInitializer() = null
|
override fun getCompileTimeInitializer() = null
|
||||||
|
|
||||||
override fun cleanCompileTimeInitializerCache() {}
|
|
||||||
|
|
||||||
override fun getSource(): SourceElement = classDescriptor.source
|
override fun getSource(): SourceElement = classDescriptor.source
|
||||||
|
|
||||||
override fun isConst(): Boolean = false
|
override fun isConst(): Boolean = false
|
||||||
|
|||||||
+2
-2
@@ -148,8 +148,8 @@ public class JavaPropertyDescriptor extends PropertyDescriptorImpl implements Ja
|
|||||||
|
|
||||||
enhanced.initialize(newGetter, newSetter, getBackingField(), getDelegateField());
|
enhanced.initialize(newGetter, newSetter, getBackingField(), getDelegateField());
|
||||||
enhanced.setSetterProjectedOut(isSetterProjectedOut());
|
enhanced.setSetterProjectedOut(isSetterProjectedOut());
|
||||||
if (compileTimeInitializerFactory != null) {
|
if (compileTimeInitializer != null) {
|
||||||
enhanced.setCompileTimeInitializer(compileTimeInitializer, compileTimeInitializerFactory);
|
enhanced.setCompileTimeInitializer(compileTimeInitializer);
|
||||||
}
|
}
|
||||||
|
|
||||||
enhanced.setOverriddenDescriptors(getOverriddenDescriptors());
|
enhanced.setOverriddenDescriptors(getOverriddenDescriptors());
|
||||||
|
|||||||
+2
-2
@@ -307,11 +307,11 @@ abstract class LazyJavaScope(
|
|||||||
)
|
)
|
||||||
|
|
||||||
if (DescriptorUtils.shouldRecordInitializerForProperty(propertyDescriptor, propertyDescriptor.type)) {
|
if (DescriptorUtils.shouldRecordInitializerForProperty(propertyDescriptor, propertyDescriptor.type)) {
|
||||||
propertyDescriptor.setCompileTimeInitializerFactory {
|
propertyDescriptor.setCompileTimeInitializer(
|
||||||
c.storageManager.createNullableLazyValue {
|
c.storageManager.createNullableLazyValue {
|
||||||
c.components.javaPropertyInitializerEvaluator.getInitializerConstant(field, propertyDescriptor)
|
c.components.javaPropertyInitializerEvaluator.getInitializerConstant(field, propertyDescriptor)
|
||||||
}
|
}
|
||||||
}
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
c.components.javaResolverCache.recordField(field, propertyDescriptor)
|
c.components.javaResolverCache.recordField(field, propertyDescriptor)
|
||||||
|
|||||||
@@ -31,11 +31,6 @@ public interface VariableDescriptor extends ValueDescriptor {
|
|||||||
@Nullable
|
@Nullable
|
||||||
ConstantValue<?> getCompileTimeInitializer();
|
ConstantValue<?> getCompileTimeInitializer();
|
||||||
|
|
||||||
/**
|
|
||||||
* ONLY FOR IDE USE! Please don't use the method inside the compiler
|
|
||||||
*/
|
|
||||||
void cleanCompileTimeInitializerCache();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return true if iff original declaration has appropriate flags and type, e.g. `const` modifier in Kotlin.
|
* @return true if iff original declaration has appropriate flags and type, e.g. `const` modifier in Kotlin.
|
||||||
* It completely does not means that if isConst then `getCompileTimeInitializer` is not null
|
* It completely does not means that if isConst then `getCompileTimeInitializer` is not null
|
||||||
|
|||||||
+3
-2
@@ -17,6 +17,7 @@
|
|||||||
package org.jetbrains.kotlin.descriptors.impl;
|
package org.jetbrains.kotlin.descriptors.impl;
|
||||||
|
|
||||||
import kotlin.annotations.jvm.ReadOnly;
|
import kotlin.annotations.jvm.ReadOnly;
|
||||||
|
import kotlin.collections.CollectionsKt;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.kotlin.descriptors.*;
|
import org.jetbrains.kotlin.descriptors.*;
|
||||||
@@ -524,8 +525,8 @@ public class PropertyDescriptorImpl extends VariableDescriptorWithInitializerImp
|
|||||||
substitutedDescriptor.setOverriddenDescriptors(overridden);
|
substitutedDescriptor.setOverriddenDescriptors(overridden);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isConst() && compileTimeInitializerFactory != null) {
|
if (isConst() && compileTimeInitializer != null) {
|
||||||
substitutedDescriptor.setCompileTimeInitializer(compileTimeInitializer, compileTimeInitializerFactory);
|
substitutedDescriptor.setCompileTimeInitializer(compileTimeInitializer);
|
||||||
}
|
}
|
||||||
|
|
||||||
return substitutedDescriptor;
|
return substitutedDescriptor;
|
||||||
|
|||||||
-3
@@ -113,9 +113,6 @@ open class ValueParameterDescriptorImpl(
|
|||||||
override fun isVar() = false
|
override fun isVar() = false
|
||||||
|
|
||||||
override fun getCompileTimeInitializer() = null
|
override fun getCompileTimeInitializer() = null
|
||||||
|
|
||||||
override fun cleanCompileTimeInitializerCache() {}
|
|
||||||
|
|
||||||
override fun copy(newOwner: CallableDescriptor, newName: Name, newIndex: Int): ValueParameterDescriptor {
|
override fun copy(newOwner: CallableDescriptor, newName: Name, newIndex: Int): ValueParameterDescriptor {
|
||||||
return ValueParameterDescriptorImpl(
|
return ValueParameterDescriptorImpl(
|
||||||
newOwner, null, newIndex, annotations, newName, type, declaresDefaultValue(),
|
newOwner, null, newIndex, annotations, newName, type, declaresDefaultValue(),
|
||||||
|
|||||||
+2
-18
@@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.descriptors.impl;
|
package org.jetbrains.kotlin.descriptors.impl;
|
||||||
|
|
||||||
import kotlin.jvm.functions.Function0;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor;
|
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor;
|
||||||
@@ -31,7 +30,6 @@ public abstract class VariableDescriptorWithInitializerImpl extends VariableDesc
|
|||||||
private final boolean isVar;
|
private final boolean isVar;
|
||||||
|
|
||||||
protected NullableLazyValue<ConstantValue<?>> compileTimeInitializer;
|
protected NullableLazyValue<ConstantValue<?>> compileTimeInitializer;
|
||||||
protected Function0<NullableLazyValue<ConstantValue<?>>> compileTimeInitializerFactory;
|
|
||||||
|
|
||||||
public VariableDescriptorWithInitializerImpl(
|
public VariableDescriptorWithInitializerImpl(
|
||||||
@NotNull DeclarationDescriptor containingDeclaration,
|
@NotNull DeclarationDescriptor containingDeclaration,
|
||||||
@@ -60,22 +58,8 @@ public abstract class VariableDescriptorWithInitializerImpl extends VariableDesc
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCompileTimeInitializerFactory(@NotNull Function0<NullableLazyValue<ConstantValue<?>>> compileTimeInitializerFactory) {
|
public void setCompileTimeInitializer(@NotNull NullableLazyValue<ConstantValue<?>> compileTimeInitializer) {
|
||||||
assert !isVar() : "Constant value for variable initializer should be recorded only for final variables: " + getName();
|
assert !isVar() : "Constant value for variable initializer should be recorded only for final variables: " + getName();
|
||||||
setCompileTimeInitializer(null, compileTimeInitializerFactory);
|
this.compileTimeInitializer = compileTimeInitializer;
|
||||||
}
|
|
||||||
|
|
||||||
public void setCompileTimeInitializer(
|
|
||||||
@Nullable NullableLazyValue<ConstantValue<?>> compileTimeInitializer,
|
|
||||||
@NotNull Function0<NullableLazyValue<ConstantValue<?>>> compileTimeInitializerFactory
|
|
||||||
) {
|
|
||||||
assert !isVar() : "Constant value for variable initializer should be recorded only for final variables: " + getName();
|
|
||||||
this.compileTimeInitializerFactory = compileTimeInitializerFactory;
|
|
||||||
this.compileTimeInitializer = compileTimeInitializer != null ? compileTimeInitializer : compileTimeInitializerFactory.invoke();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void cleanCompileTimeInitializerCache() {
|
|
||||||
this.compileTimeInitializer = compileTimeInitializerFactory.invoke();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -132,12 +132,12 @@ class MemberDeserializer(private val c: DeserializationContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Flags.HAS_CONSTANT.get(flags)) {
|
if (Flags.HAS_CONSTANT.get(flags)) {
|
||||||
property.setCompileTimeInitializerFactory {
|
property.setCompileTimeInitializer(
|
||||||
c.storageManager.createNullableLazyValue {
|
c.storageManager.createNullableLazyValue {
|
||||||
val container = c.containingDeclaration.asProtoContainer()!!
|
val container = c.containingDeclaration.asProtoContainer()!!
|
||||||
c.components.annotationAndConstantLoader.loadPropertyConstant(container, proto, property.returnType)
|
c.components.annotationAndConstantLoader.loadPropertyConstant(container, proto, property.returnType)
|
||||||
}
|
}
|
||||||
}
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((c.containingDeclaration as? ClassDescriptor)?.kind == ClassKind.ANNOTATION_CLASS) {
|
if ((c.containingDeclaration as? ClassDescriptor)?.kind == ClassKind.ANNOTATION_CLASS) {
|
||||||
|
|||||||
Reference in New Issue
Block a user