Revert "[FIR] Let attributes opt-in to participating in ConeClassLikeTypeImpl structural equality"

This reverts commit 9189154cae.
This commit is contained in:
Kirill Rakhman
2024-01-16 09:14:22 +01:00
parent 121536d2e5
commit 8c04206709
11 changed files with 92 additions and 58 deletions
@@ -32,13 +32,6 @@ abstract class ConeAttribute<out T : ConeAttribute<T>> : AnnotationMarker {
abstract override fun toString(): String
open fun renderForReadability(): String? = null
/**
* Signals that this attribute properly implements the [equals] and [hashCode] protocol.
*
* If it returns `true`, attributes will be compared using structural equality in [ConeAttributes.definitelyDifferFrom].
*/
open val implementsEquality: Boolean get() = false
abstract val key: KClass<out T>
/**
@@ -159,32 +152,6 @@ class ConeAttributes private constructor(attributes: List<ConeAttribute<*>>) : A
return create(attributes)
}
/**
* Returns `true` if this instance is definitely not equal to the [other] instance.
* This is `true` when one instance contains an attribute **type** that the other doesn't contain or both instances contain
* an attribute of a type where [ConeAttribute.implementsEquality]` == true` and the attribute's [equals] method returns `false`.
*
* A return value of `false` doesn't guarantee that the instances are equal because [ConeAttribute.implementsEquality] is optional,
* i.e., not all attributes can be compared structurally.
*
* @see org.jetbrains.kotlin.fir.types.impl.ConeClassLikeTypeImpl.equals
*/
infix fun definitelyDifferFrom(other: ConeAttributes): Boolean {
if (this === other) return false
if (this.isEmpty() && other.isEmpty()) return false
for (index in indices) {
val a = arrayMap[index]
val b = other.arrayMap[index]
if (a == null && b == null) continue
if ((a == null) != (b == null)) return true
if (a!!.implementsEquality && a != b) return true
}
return false
}
/**
* Applies the [transform] to all attributes that are subtypes of [ConeAttributeWithConeType] and returns a [ConeAttributes]
* with the results of transforms that were not-`null` or `null` if no attributes were transformed.
@@ -34,7 +34,6 @@ class ConeClassLikeTypeImpl(
if (lookupTag != other.lookupTag) return false
if (!typeArguments.contentEquals(other.typeArguments)) return false
if (nullability != other.nullability) return false
if (attributes definitelyDifferFrom other.attributes) return false
return true
}