From eed0f50c5d08a34cf657df84826890e9a417b3d0 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Wed, 20 Jan 2021 12:26:36 +0300 Subject: [PATCH] Code cleanup: ConeAttributes --- .../jetbrains/kotlin/fir/types/CompilerConeAttributes.kt | 6 +++--- .../src/org/jetbrains/kotlin/fir/types/ConeAttributes.kt | 7 ++----- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/CompilerConeAttributes.kt b/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/CompilerConeAttributes.kt index c58362c2d60..13fef591dc8 100644 --- a/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/CompilerConeAttributes.kt +++ b/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/CompilerConeAttributes.kt @@ -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 = 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 = 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 = FlexibleNullability::class 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 378fb5d1b76..a2779ca5cba 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 @@ -58,7 +58,7 @@ class ConeAttributes private constructor(attributes: List>) : 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>) : 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)