From 9266a2cdba645e8b4a6cc68dbebad5a468728c38 Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Wed, 15 May 2019 15:48:54 +0300 Subject: [PATCH] Add equals/hashCode to some FIR cone types --- .../jetbrains/kotlin/fir/types/ConeTypes.kt | 4 ++-- .../jetbrains/kotlin/fir/types/impl/Impl.kt | 20 +++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/ConeTypes.kt b/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/ConeTypes.kt index 3669a3b62bb..927413c0ad2 100644 --- a/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/ConeTypes.kt +++ b/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/ConeTypes.kt @@ -30,12 +30,12 @@ interface ConeTypedProjection { val type: ConeKotlinType } -class ConeKotlinTypeProjectionIn(override val type: ConeKotlinType) : ConeKotlinTypeProjection(), ConeTypedProjection { +data class ConeKotlinTypeProjectionIn(override val type: ConeKotlinType) : ConeKotlinTypeProjection(), ConeTypedProjection { override val kind: ProjectionKind get() = ProjectionKind.IN } -class ConeKotlinTypeProjectionOut(override val type: ConeKotlinType) : ConeKotlinTypeProjection(), ConeTypedProjection { +data class ConeKotlinTypeProjectionOut(override val type: ConeKotlinType) : ConeKotlinTypeProjection(), ConeTypedProjection { override val kind: ProjectionKind get() = ProjectionKind.OUT } diff --git a/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/impl/Impl.kt b/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/impl/Impl.kt index 9601c98a8b7..1ec5631ee6d 100644 --- a/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/impl/Impl.kt +++ b/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/impl/Impl.kt @@ -57,4 +57,24 @@ class ConeTypeParameterTypeImpl( get() = EMPTY_ARRAY override val nullability: ConeNullability = ConeNullability.create(isNullable) + + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + + other as ConeTypeParameterTypeImpl + + if (lookupTag != other.lookupTag) return false + if (nullability != other.nullability) return false + + return true + } + + override fun hashCode(): Int { + var result = lookupTag.hashCode() + result = 31 * result + nullability.hashCode() + return result + } + }