Change the order of final properties initialization and ctor
To avoid case with NPE due to race-condition on publishing non-fully initialized object in ctor via `TypeRefinementSupport.Enabled(this)` #KT-59852 Merge-request: KT-MR-10917 Merged-by: Vladimir Dolzhenko <Vladimir.Dolzhenko@jetbrains.com>
This commit is contained in:
committed by
Space Team
parent
c7ae3c75db
commit
4a7aea0dc6
@@ -11,6 +11,7 @@ import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.classId
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.module
|
||||
import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
||||
import org.jetbrains.kotlin.storage.CacheWithNotNullValues
|
||||
import org.jetbrains.kotlin.storage.LockBasedStorageManager
|
||||
import org.jetbrains.kotlin.storage.StorageManager
|
||||
import org.jetbrains.kotlin.types.checker.KotlinTypeRefiner
|
||||
@@ -25,6 +26,12 @@ class KotlinTypeRefinerImpl(
|
||||
private val moduleDescriptor: ModuleDescriptor,
|
||||
storageManager: StorageManager
|
||||
) : KotlinTypeRefiner() {
|
||||
private val refinedTypeCache: CacheWithNotNullValues<TypeConstructor, KotlinType> =
|
||||
storageManager.createCacheWithNotNullValues()
|
||||
private val isRefinementNeededForTypeConstructorCache: CacheWithNotNullValues<ClassifierDescriptor, Boolean> =
|
||||
storageManager.createCacheWithNotNullValues()
|
||||
private val scopes: CacheWithNotNullValues<ClassDescriptor, MemberScope> =
|
||||
storageManager.createCacheWithNotNullValues()
|
||||
private var isStandalone: Boolean = false
|
||||
|
||||
private constructor(
|
||||
@@ -41,10 +48,6 @@ class KotlinTypeRefinerImpl(
|
||||
}
|
||||
}
|
||||
|
||||
private val refinedTypeCache = storageManager.createCacheWithNotNullValues<TypeConstructor, KotlinType>()
|
||||
private val isRefinementNeededForTypeConstructorCache = storageManager.createCacheWithNotNullValues<ClassifierDescriptor, Boolean>()
|
||||
private val scopes = storageManager.createCacheWithNotNullValues<ClassDescriptor, MemberScope>()
|
||||
|
||||
/**
|
||||
* IMPORTANT: that function has not obvious contract: it refines only supertypes,
|
||||
* and don't refines type arguments, so return type is "partly refined".
|
||||
|
||||
Reference in New Issue
Block a user