Code cleanup: ConeAttributes

This commit is contained in:
Mikhail Glukhikh
2021-01-20 12:26:36 +03:00
parent 94e613dd01
commit eed0f50c5d
2 changed files with 5 additions and 8 deletions
@@ -39,7 +39,7 @@ object CompilerConeAttributes {
val ANNOTATION_CLASS_ID = ClassId(FqName("kotlin.jvm.internal"), Name.identifier("EnhancedNullability"))
override fun union(other: EnhancedNullability?): EnhancedNullability? = other
override fun intersect(other: EnhancedNullability?): EnhancedNullability? = this
override fun intersect(other: EnhancedNullability?): EnhancedNullability = this
override fun isSubtypeOf(other: EnhancedNullability?): Boolean = true
override val key: KClass<out EnhancedNullability> = EnhancedNullability::class
@@ -51,7 +51,7 @@ object CompilerConeAttributes {
val ANNOTATION_CLASS_ID = ClassId(FqName("kotlin"), Name.identifier("ExtensionFunctionType"))
override fun union(other: ExtensionFunctionType?): ExtensionFunctionType? = other
override fun intersect(other: ExtensionFunctionType?): ExtensionFunctionType? = this
override fun intersect(other: ExtensionFunctionType?): ExtensionFunctionType = this
override fun isSubtypeOf(other: ExtensionFunctionType?): Boolean = true
override val key: KClass<out ExtensionFunctionType> = ExtensionFunctionType::class
@@ -63,7 +63,7 @@ object CompilerConeAttributes {
val ANNOTATION_CLASS_ID = ClassId(FqName("kotlin.internal.ir"), Name.identifier("FlexibleNullability"))
override fun union(other: FlexibleNullability?): FlexibleNullability? = other
override fun intersect(other: FlexibleNullability?): FlexibleNullability? = this
override fun intersect(other: FlexibleNullability?): FlexibleNullability = this
override fun isSubtypeOf(other: FlexibleNullability?): Boolean = true
override val key: KClass<out FlexibleNullability> = FlexibleNullability::class
@@ -58,7 +58,7 @@ class ConeAttributes private constructor(attributes: List<ConeAttribute<*>>) : A
val hasEnhancedNullability: Boolean
get() = enhancedNullability != null
val hasFlexibleNullability: Boolean
private val hasFlexibleNullability: Boolean
get() = flexibleNullability != null
fun union(other: ConeAttributes): ConeAttributes {
@@ -79,10 +79,7 @@ class ConeAttributes private constructor(attributes: List<ConeAttribute<*>>) : A
for (index in indices) {
val a = arrayMap[index]
val b = other.arrayMap[index]
val res = when {
a == null -> b?.op(a)
else -> a.op(b)
}
val res = if (a == null) b?.op(a) else a.op(b)
attributes.addIfNotNull(res)
}
return create(attributes)