FIR: Implement ConeTypeVariableType::equals/hashCode manually

`typeAttributes` are not considered as a part of equality for other type kinds
This commit is contained in:
Denis.Zharkov
2021-11-15 16:10:05 +03:00
committed by teamcityserver
parent c0b6a593e0
commit e26abbbbb0
@@ -91,6 +91,7 @@ sealed class ConeKotlinType : ConeKotlinTypeProjection(), KotlinTypeMarker, Type
final override fun toString(): String { final override fun toString(): String {
return render() return render()
} }
abstract override fun equals(other: Any?): Boolean abstract override fun equals(other: Any?): Boolean
abstract override fun hashCode(): Int abstract override fun hashCode(): Int
} }
@@ -224,12 +225,30 @@ data class ConeCapturedType(
} }
} }
data class ConeTypeVariableType( class ConeTypeVariableType(
override val nullability: ConeNullability, override val nullability: ConeNullability,
override val lookupTag: ConeTypeVariableTypeConstructor, override val lookupTag: ConeTypeVariableTypeConstructor,
override val attributes: ConeAttributes = ConeAttributes.Empty, override val attributes: ConeAttributes = ConeAttributes.Empty,
) : ConeLookupTagBasedType() { ) : ConeLookupTagBasedType() {
override val typeArguments: Array<out ConeTypeProjection> get() = emptyArray() override val typeArguments: Array<out ConeTypeProjection> get() = emptyArray()
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (other !is ConeTypeVariableType) return false
if (nullability != other.nullability) return false
if (lookupTag != other.lookupTag) return false
return true
}
override fun hashCode(): Int {
var result = 0
result = 31 * result + nullability.hashCode()
result = 31 * result + lookupTag.hashCode()
return result
}
} }
data class ConeDefinitelyNotNullType(val original: ConeKotlinType) : ConeSimpleKotlinType(), DefinitelyNotNullTypeMarker { data class ConeDefinitelyNotNullType(val original: ConeKotlinType) : ConeSimpleKotlinType(), DefinitelyNotNullTypeMarker {