[FIR] Add KDoc about thread safety rules of FirDeclarationAttributes

This commit is contained in:
Dmitriy Novozhilov
2021-09-03 13:54:37 +03:00
committed by TeamCityServer
parent a13696072d
commit 9844671ded
@@ -15,6 +15,14 @@ import kotlin.reflect.KProperty
abstract class FirDeclarationDataKey
/**
* Please note that FirDeclarationAttributes itself is thread unsafe, so when you read
* or write some attribute you need to ensure that this operation is safe and there
* won't be any race condition. You can achieve this by
* - setting attribute to declaration before it's publication (e.g. in scopes)
* - setting attribute in one phase and reading it only in following ones (using `ensureResolve` on symbol)
* - resetting attribute under lock over specific attribute value
*/
class FirDeclarationAttributes : AttributeArrayOwner<FirDeclarationDataKey, Any> {
override val typeRegistry: TypeRegistry<FirDeclarationDataKey, Any>
get() = FirDeclarationDataRegistry