Fix deadlock on static initializers of KProperty implementations
#KT-10041 Fixed
This commit is contained in:
@@ -19,7 +19,6 @@ package kotlin.reflect.jvm.internal
|
||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
||||
import org.jetbrains.kotlin.serialization.jvm.JvmProtoBufUtil
|
||||
import java.lang.reflect.Field
|
||||
import kotlin.reflect.KProperty
|
||||
import kotlin.reflect.jvm.internal.JvmPropertySignature.JavaField
|
||||
import kotlin.reflect.jvm.internal.JvmPropertySignature.KotlinProperty
|
||||
|
||||
@@ -40,11 +39,13 @@ internal abstract class DescriptorBasedProperty<out R> protected constructor(
|
||||
descriptor
|
||||
)
|
||||
|
||||
override val descriptor: PropertyDescriptor by ReflectProperties.lazySoft<PropertyDescriptor>(descriptorInitialValue) {
|
||||
private val descriptor_ = ReflectProperties.lazySoft<PropertyDescriptor>(descriptorInitialValue) {
|
||||
container.findPropertyDescriptor(name, signature)
|
||||
}
|
||||
|
||||
val javaField: Field? by ReflectProperties.lazySoft {
|
||||
override val descriptor: PropertyDescriptor get() = descriptor_()
|
||||
|
||||
private val javaField_ = ReflectProperties.lazySoft {
|
||||
val jvmSignature = RuntimeTypeMapper.mapPropertySignature(descriptor)
|
||||
when (jvmSignature) {
|
||||
is KotlinProperty -> {
|
||||
@@ -56,6 +57,9 @@ internal abstract class DescriptorBasedProperty<out R> protected constructor(
|
||||
}
|
||||
}
|
||||
|
||||
// Used in subclasses as an implementation of an irrelevant property from KPropertyImpl
|
||||
val javaField: Field? get() = javaField_()
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
val that = other.asKPropertyImpl() ?: return false
|
||||
return container == that.container && name == that.name && signature == that.signature
|
||||
|
||||
@@ -25,7 +25,9 @@ internal open class KProperty0Impl<out R> : DescriptorBasedProperty<R>, KPropert
|
||||
|
||||
constructor(container: KDeclarationContainerImpl, name: String, signature: String) : super(container, name, signature)
|
||||
|
||||
override val getter by ReflectProperties.lazy { Getter(this) }
|
||||
private val getter_ = ReflectProperties.lazy { Getter(this) }
|
||||
|
||||
override val getter: Getter<R> get() = getter_()
|
||||
|
||||
override fun get(): R = getter.call()
|
||||
|
||||
@@ -39,7 +41,9 @@ internal open class KMutableProperty0Impl<R> : KProperty0Impl<R>, KMutableProper
|
||||
|
||||
constructor(container: KDeclarationContainerImpl, name: String, signature: String) : super(container, name, signature)
|
||||
|
||||
override val setter by ReflectProperties.lazy { Setter(this) }
|
||||
private val setter_ = ReflectProperties.lazy { Setter(this) }
|
||||
|
||||
override val setter: Setter<R> get() = setter_()
|
||||
|
||||
override fun set(value: R) = setter.call(value)
|
||||
|
||||
|
||||
@@ -25,7 +25,9 @@ internal open class KProperty1Impl<T, out R> : DescriptorBasedProperty<R>, KProp
|
||||
|
||||
constructor(container: KDeclarationContainerImpl, descriptor: PropertyDescriptor) : super(container, descriptor)
|
||||
|
||||
override val getter by ReflectProperties.lazy { Getter(this) }
|
||||
private val getter_ = ReflectProperties.lazy { Getter(this) }
|
||||
|
||||
override val getter: Getter<T, R> get() = getter_()
|
||||
|
||||
override fun get(receiver: T): R = getter.call(receiver)
|
||||
|
||||
@@ -39,7 +41,9 @@ internal open class KMutableProperty1Impl<T, R> : KProperty1Impl<T, R>, KMutable
|
||||
|
||||
constructor(container: KDeclarationContainerImpl, descriptor: PropertyDescriptor) : super(container, descriptor)
|
||||
|
||||
override val setter by ReflectProperties.lazy { Setter(this) }
|
||||
private val setter_ = ReflectProperties.lazy { Setter(this) }
|
||||
|
||||
override val setter: Setter<T, R> get() = setter_()
|
||||
|
||||
override fun set(receiver: T, value: R) = setter.call(receiver, value)
|
||||
|
||||
|
||||
@@ -25,7 +25,9 @@ internal open class KProperty2Impl<D, E, out R> : DescriptorBasedProperty<R>, KP
|
||||
|
||||
constructor(container: KDeclarationContainerImpl, descriptor: PropertyDescriptor) : super(container, descriptor)
|
||||
|
||||
override val getter by ReflectProperties.lazy { Getter(this) }
|
||||
private val getter_ = ReflectProperties.lazy { Getter(this) }
|
||||
|
||||
override val getter: Getter<D, E, R> get() = getter_()
|
||||
|
||||
override fun get(receiver1: D, receiver2: E): R = getter.call(receiver1, receiver2)
|
||||
|
||||
@@ -39,7 +41,9 @@ internal open class KMutableProperty2Impl<D, E, R> : KProperty2Impl<D, E, R>, KM
|
||||
|
||||
constructor(container: KDeclarationContainerImpl, descriptor: PropertyDescriptor) : super(container, descriptor)
|
||||
|
||||
override val setter by ReflectProperties.lazy { Setter(this) }
|
||||
private val setter_ = ReflectProperties.lazy { Setter(this) }
|
||||
|
||||
override val setter: Setter<D, E, R> get() = setter_()
|
||||
|
||||
override fun set(receiver1: D, receiver2: E, value: R) = setter.call(receiver1, receiver2, value)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user