From ac51e5dbd1af52513ccf9d4e1237bf05650882cd Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Fri, 26 Jun 2020 16:28:37 +0300 Subject: [PATCH] [FIR] Add workaround for KT-19306 --- .../src/org/jetbrains/kotlin/fir/types/ConeAttributes.kt | 2 ++ .../src/org/jetbrains/kotlin/fir/utils/ArrayMapOwner.kt | 8 +++++++- .../org/jetbrains/kotlin/fir/utils/AttributeArrayOwner.kt | 1 + .../org/jetbrains/kotlin/fir/utils/ComponentArrayOwner.kt | 1 + .../kotlin/fir/extensions/FirExtensionService.kt | 2 ++ 5 files changed, 13 insertions(+), 1 deletion(-) diff --git a/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/ConeAttributes.kt b/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/ConeAttributes.kt index fa7354b66de..94bb1b45ae6 100644 --- a/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/ConeAttributes.kt +++ b/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/ConeAttributes.kt @@ -6,6 +6,7 @@ package org.jetbrains.kotlin.fir.types import org.jetbrains.kotlin.fir.utils.AttributeArrayOwner +import org.jetbrains.kotlin.fir.utils.Protected import org.jetbrains.kotlin.fir.utils.TypeRegistry import org.jetbrains.kotlin.fir.utils.isEmpty import org.jetbrains.kotlin.utils.addIfNotNull @@ -20,6 +21,7 @@ abstract class ConeAttribute> { abstract val key: KClass } +@OptIn(Protected::class) class ConeAttributes private constructor(attributes: List>) : AttributeArrayOwner, ConeAttribute<*>>() { companion object : TypeRegistry, ConeAttribute<*>>() { inline fun > attributeAccessor(): ReadOnlyProperty { diff --git a/compiler/fir/cones/src/org/jetbrains/kotlin/fir/utils/ArrayMapOwner.kt b/compiler/fir/cones/src/org/jetbrains/kotlin/fir/utils/ArrayMapOwner.kt index 5ed03531cf4..425471e99cf 100644 --- a/compiler/fir/cones/src/org/jetbrains/kotlin/fir/utils/ArrayMapOwner.kt +++ b/compiler/fir/cones/src/org/jetbrains/kotlin/fir/utils/ArrayMapOwner.kt @@ -10,8 +10,14 @@ import kotlin.properties.ReadOnlyProperty import kotlin.reflect.KClass import kotlin.reflect.KProperty +@RequiresOptIn +annotation class Protected + +@OptIn(Protected::class) abstract class AbstractArrayMapOwner { - protected abstract val arrayMap: ArrayMap + // TODO: make [arrayMap] protected and remove annotation after KT-19306 fix + @get:Protected + abstract val arrayMap: ArrayMap protected abstract val typeRegistry: TypeRegistry abstract class AbstractArrayMapAccessor( diff --git a/compiler/fir/cones/src/org/jetbrains/kotlin/fir/utils/AttributeArrayOwner.kt b/compiler/fir/cones/src/org/jetbrains/kotlin/fir/utils/AttributeArrayOwner.kt index 0d73688dbc5..e0c4881d21e 100644 --- a/compiler/fir/cones/src/org/jetbrains/kotlin/fir/utils/AttributeArrayOwner.kt +++ b/compiler/fir/cones/src/org/jetbrains/kotlin/fir/utils/AttributeArrayOwner.kt @@ -16,6 +16,7 @@ import kotlin.reflect.KClass * Note that you can remove attributes from [AttributeArrayOwner] despite * from components in [ComponentArrayOwner] */ +@OptIn(Protected::class) abstract class AttributeArrayOwner : AbstractArrayMapOwner() { @Suppress("UNCHECKED_CAST") final override var arrayMap: ArrayMap = EmptyArrayMap as ArrayMap diff --git a/compiler/fir/cones/src/org/jetbrains/kotlin/fir/utils/ComponentArrayOwner.kt b/compiler/fir/cones/src/org/jetbrains/kotlin/fir/utils/ComponentArrayOwner.kt index 26e33286940..e2610ed1d01 100644 --- a/compiler/fir/cones/src/org/jetbrains/kotlin/fir/utils/ComponentArrayOwner.kt +++ b/compiler/fir/cones/src/org/jetbrains/kotlin/fir/utils/ComponentArrayOwner.kt @@ -11,6 +11,7 @@ import kotlin.reflect.KClass * [ComponentArrayOwner] based on [ArrayMap] with flexible size and should be used for * storing services in entities with limited number of instances, like FirSession */ +@OptIn(Protected::class) abstract class ComponentArrayOwner : AbstractArrayMapOwner() { final override val arrayMap: ArrayMap = ArrayMapImpl() diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/extensions/FirExtensionService.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/extensions/FirExtensionService.kt index a44d6be1cef..f368dd9d201 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/extensions/FirExtensionService.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/extensions/FirExtensionService.kt @@ -9,6 +9,7 @@ import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.FirSessionComponent import org.jetbrains.kotlin.fir.utils.ArrayMapAccessor import org.jetbrains.kotlin.fir.utils.ComponentArrayOwner +import org.jetbrains.kotlin.fir.utils.Protected import org.jetbrains.kotlin.fir.utils.TypeRegistry import kotlin.reflect.KClass @@ -47,6 +48,7 @@ class FirExtensionService(val session: FirSession) : ComponentArrayOwner { return arrayMap.flatten() }