Revert "[FIR] Let attributes opt-in to participating in ConeClassLikeTypeImpl structural equality"
This reverts commit c39262195dbd31785f220f0eb07e860975567b2b.
diff --git a/analysis/low-level-api-fir/testData/lazyResolve/syntheticProperties/explicitReturnTypeAndAnnotations.txt b/analysis/low-level-api-fir/testData/lazyResolve/syntheticProperties/explicitReturnTypeAndAnnotations.txt
index ca2417b..60a9037 100644
--- a/analysis/low-level-api-fir/testData/lazyResolve/syntheticProperties/explicitReturnTypeAndAnnotations.txt
+++ b/analysis/low-level-api-fir/testData/lazyResolve/syntheticProperties/explicitReturnTypeAndAnnotations.txt
@@ -141,7 +141,7 @@
BODY_RESOLVE:
TARGET: public open override [<synthetic> BODY_RESOLVE] val something: R|@R|Anno|(s = <strcat>(String(type: ), R|/prop|)) kotlin/String|
@R|Anno|[Types](s = <strcat>(String(number: ), R|/prop|)) public [<synthetic> ResolvedTo(BODY_RESOLVE)] get(): R|@R|Anno|(s = <strcat>(String(type: ), R|/prop|)) kotlin/String| {
- ^getSomething String(str).R|kotlin/also|<R|kotlin/String|>(::R|kotlin/io/println|)
+ ^getSomething String(str).R|kotlin/also|<R|@R|Anno|(s = <strcat>(String(type: ), R|/prop|)) kotlin/String|>(::R|kotlin/io/println|)
}
FILE: [ResolvedTo(IMPORTS)] Derived.kt
@@ -151,7 +151,7 @@
}
@R|Anno|[Types](s = <strcat>(String(number: ), R|/prop|)) public open override [ResolvedTo(BODY_RESOLVE)] fun getSomething(): R|@R|Anno|(s = <strcat>(String(type: ), R|/prop|)) kotlin/String| {
- ^getSomething String(str).R|kotlin/also|<R|kotlin/String|>(::R|kotlin/io/println|)
+ ^getSomething String(str).R|kotlin/also|<R|@R|Anno|(s = <strcat>(String(type: ), R|/prop|)) kotlin/String|>(::R|kotlin/io/println|)
}
}
@@ -178,7 +178,7 @@
}
@R|Anno|[Types](s = <strcat>(String(number: ), R|/prop|)) public open override [ResolvedTo(BODY_RESOLVE)] fun getSomething(): R|@R|Anno|(s = <strcat>(String(type: ), R|/prop|)) kotlin/String| {
- ^getSomething String(str).R|kotlin/also|<R|kotlin/String|>(::R|kotlin/io/println|)
+ ^getSomething String(str).R|kotlin/also|<R|@R|Anno|(s = <strcat>(String(type: ), R|/prop|)) kotlin/String|>(::R|kotlin/io/println|)
}
}
diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirPropertyAccessorsTypesChecker.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirPropertyAccessorsTypesChecker.kt
index 91527bd..401d73f 100644
--- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirPropertyAccessorsTypesChecker.kt
+++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirPropertyAccessorsTypesChecker.kt
@@ -18,7 +18,10 @@
import org.jetbrains.kotlin.fir.declarations.utils.canHaveAbstractDeclaration
import org.jetbrains.kotlin.fir.declarations.utils.isAbstract
import org.jetbrains.kotlin.fir.declarations.utils.visibility
-import org.jetbrains.kotlin.fir.types.*
+import org.jetbrains.kotlin.fir.types.ConeErrorType
+import org.jetbrains.kotlin.fir.types.coneType
+import org.jetbrains.kotlin.fir.types.hasError
+import org.jetbrains.kotlin.fir.types.isUnit
object FirPropertyAccessorsTypesChecker : FirPropertyChecker() {
override fun check(declaration: FirProperty, context: CheckerContext, reporter: DiagnosticReporter) {
@@ -97,7 +100,7 @@
return
}
- if (valueSetterType.withAttributes(ConeAttributes.Empty) != propertyType.withAttributes(ConeAttributes.Empty) && !valueSetterType.hasError()) {
+ if (valueSetterType != propertyType && !valueSetterType.hasError()) {
reporter.reportOn(valueSetterTypeSource, FirErrors.WRONG_SETTER_PARAMETER_TYPE, propertyType, valueSetterType, context)
}
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 d358fc9..9855a3ac 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
@@ -32,13 +32,6 @@
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>
/**
@@ -160,32 +153,6 @@
}
/**
- * 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.
*/
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 ee2771a..f02a92f 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
@@ -34,7 +34,6 @@
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
}
diff --git a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/enhancement/EnhancedTypeForWarningAttribute.kt b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/enhancement/EnhancedTypeForWarningAttribute.kt
index ad0c881..4078015 100644
--- a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/enhancement/EnhancedTypeForWarningAttribute.kt
+++ b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/enhancement/EnhancedTypeForWarningAttribute.kt
@@ -25,25 +25,6 @@
override val keepInInferredDeclarationType: Boolean
get() = true
-
- override val implementsEquality: Boolean
- get() = true
-
- override fun equals(other: Any?): Boolean {
- if (this === other) return true
- if (javaClass != other?.javaClass) return false
-
- other as EnhancedTypeForWarningAttribute
-
- if (coneType != other.coneType) return false
-
- return true
- }
-
- override fun hashCode(): Int {
- var result = coneType.hashCode()
- return result
- }
}
val ConeAttributes.enhancedTypeForWarning: EnhancedTypeForWarningAttribute? by ConeAttributes.attributeAccessor<EnhancedTypeForWarningAttribute>()
diff --git a/compiler/testData/codegen/box/casts/mutableCollections/asWithMutable.jvm_abi.txt b/compiler/testData/codegen/box/casts/mutableCollections/asWithMutable.jvm_abi.txt
index 98aa5a7..164ab4f 100644
--- a/compiler/testData/codegen/box/casts/mutableCollections/asWithMutable.jvm_abi.txt
+++ b/compiler/testData/codegen/box/casts/mutableCollections/asWithMutable.jvm_abi.txt
@@ -1,4 +1,18 @@
MODULE main
+ CLASS MLItr.class
+ CLASS METADATA
+ FUNCTION add(Ljava/lang/String;)V
+ Property: class.metadata.function.valueParameters
+ K1
+ (element: kotlin/String)
+ K2
+ (element: @kotlin/jvm/internal/EnhancedNullability kotlin/String)
+ FUNCTION set(Ljava/lang/String;)V
+ Property: class.metadata.function.valueParameters
+ K1
+ (element: kotlin/String)
+ K2
+ (element: @kotlin/jvm/internal/EnhancedNullability kotlin/String)
CLASS C.class
CLASS METADATA
K1
diff --git a/compiler/testData/codegen/box/casts/mutableCollections/isWithMutable.jvm_abi.txt b/compiler/testData/codegen/box/casts/mutableCollections/isWithMutable.jvm_abi.txt
index 98aa5a7..164ab4f 100644
--- a/compiler/testData/codegen/box/casts/mutableCollections/isWithMutable.jvm_abi.txt
+++ b/compiler/testData/codegen/box/casts/mutableCollections/isWithMutable.jvm_abi.txt
@@ -1,4 +1,18 @@
MODULE main
+ CLASS MLItr.class
+ CLASS METADATA
+ FUNCTION add(Ljava/lang/String;)V
+ Property: class.metadata.function.valueParameters
+ K1
+ (element: kotlin/String)
+ K2
+ (element: @kotlin/jvm/internal/EnhancedNullability kotlin/String)
+ FUNCTION set(Ljava/lang/String;)V
+ Property: class.metadata.function.valueParameters
+ K1
+ (element: kotlin/String)
+ K2
+ (element: @kotlin/jvm/internal/EnhancedNullability kotlin/String)
CLASS C.class
CLASS METADATA
K1
diff --git a/compiler/testData/codegen/box/casts/mutableCollections/reifiedAsWithMutable.jvm_abi.txt b/compiler/testData/codegen/box/casts/mutableCollections/reifiedAsWithMutable.jvm_abi.txt
index 98aa5a7..164ab4f 100644
--- a/compiler/testData/codegen/box/casts/mutableCollections/reifiedAsWithMutable.jvm_abi.txt
+++ b/compiler/testData/codegen/box/casts/mutableCollections/reifiedAsWithMutable.jvm_abi.txt
@@ -1,4 +1,18 @@
MODULE main
+ CLASS MLItr.class
+ CLASS METADATA
+ FUNCTION add(Ljava/lang/String;)V
+ Property: class.metadata.function.valueParameters
+ K1
+ (element: kotlin/String)
+ K2
+ (element: @kotlin/jvm/internal/EnhancedNullability kotlin/String)
+ FUNCTION set(Ljava/lang/String;)V
+ Property: class.metadata.function.valueParameters
+ K1
+ (element: kotlin/String)
+ K2
+ (element: @kotlin/jvm/internal/EnhancedNullability kotlin/String)
CLASS C.class
CLASS METADATA
K1
diff --git a/compiler/testData/codegen/box/casts/mutableCollections/reifiedIsWithMutable.jvm_abi.txt b/compiler/testData/codegen/box/casts/mutableCollections/reifiedIsWithMutable.jvm_abi.txt
index 98aa5a7..164ab4f 100644
--- a/compiler/testData/codegen/box/casts/mutableCollections/reifiedIsWithMutable.jvm_abi.txt
+++ b/compiler/testData/codegen/box/casts/mutableCollections/reifiedIsWithMutable.jvm_abi.txt
@@ -1,4 +1,18 @@
MODULE main
+ CLASS MLItr.class
+ CLASS METADATA
+ FUNCTION add(Ljava/lang/String;)V
+ Property: class.metadata.function.valueParameters
+ K1
+ (element: kotlin/String)
+ K2
+ (element: @kotlin/jvm/internal/EnhancedNullability kotlin/String)
+ FUNCTION set(Ljava/lang/String;)V
+ Property: class.metadata.function.valueParameters
+ K1
+ (element: kotlin/String)
+ K2
+ (element: @kotlin/jvm/internal/EnhancedNullability kotlin/String)
CLASS C.class
CLASS METADATA
K1
diff --git a/compiler/testData/codegen/box/casts/mutableCollections/reifiedSafeAsWithMutable.jvm_abi.txt b/compiler/testData/codegen/box/casts/mutableCollections/reifiedSafeAsWithMutable.jvm_abi.txt
index 98aa5a7..164ab4f 100644
--- a/compiler/testData/codegen/box/casts/mutableCollections/reifiedSafeAsWithMutable.jvm_abi.txt
+++ b/compiler/testData/codegen/box/casts/mutableCollections/reifiedSafeAsWithMutable.jvm_abi.txt
@@ -1,4 +1,18 @@
MODULE main
+ CLASS MLItr.class
+ CLASS METADATA
+ FUNCTION add(Ljava/lang/String;)V
+ Property: class.metadata.function.valueParameters
+ K1
+ (element: kotlin/String)
+ K2
+ (element: @kotlin/jvm/internal/EnhancedNullability kotlin/String)
+ FUNCTION set(Ljava/lang/String;)V
+ Property: class.metadata.function.valueParameters
+ K1
+ (element: kotlin/String)
+ K2
+ (element: @kotlin/jvm/internal/EnhancedNullability kotlin/String)
CLASS C.class
CLASS METADATA
K1
diff --git a/compiler/testData/codegen/box/casts/mutableCollections/safeAsWithMutable.jvm_abi.txt b/compiler/testData/codegen/box/casts/mutableCollections/safeAsWithMutable.jvm_abi.txt
index 98aa5a7..164ab4f 100644
--- a/compiler/testData/codegen/box/casts/mutableCollections/safeAsWithMutable.jvm_abi.txt
+++ b/compiler/testData/codegen/box/casts/mutableCollections/safeAsWithMutable.jvm_abi.txt
@@ -1,4 +1,18 @@
MODULE main
+ CLASS MLItr.class
+ CLASS METADATA
+ FUNCTION add(Ljava/lang/String;)V
+ Property: class.metadata.function.valueParameters
+ K1
+ (element: kotlin/String)
+ K2
+ (element: @kotlin/jvm/internal/EnhancedNullability kotlin/String)
+ FUNCTION set(Ljava/lang/String;)V
+ Property: class.metadata.function.valueParameters
+ K1
+ (element: kotlin/String)
+ K2
+ (element: @kotlin/jvm/internal/EnhancedNullability kotlin/String)
CLASS C.class
CLASS METADATA
K1