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 ca2417bbfab..60a9037f3fd 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 @@ FILE: [ResolvedTo(IMPORTS)] Derived.kt BODY_RESOLVE: TARGET: public open override [ BODY_RESOLVE] val something: R|@R|Anno|(s = (String(type: ), R|/prop|)) kotlin/String| @R|Anno|[Types](s = (String(number: ), R|/prop|)) public [ ResolvedTo(BODY_RESOLVE)] get(): R|@R|Anno|(s = (String(type: ), R|/prop|)) kotlin/String| { - ^getSomething String(str).R|kotlin/also|(::R|kotlin/io/println|) + ^getSomething String(str).R|kotlin/also|(String(type: ), R|/prop|)) kotlin/String|>(::R|kotlin/io/println|) } FILE: [ResolvedTo(IMPORTS)] Derived.kt @@ -151,7 +151,7 @@ FILE: [ResolvedTo(IMPORTS)] Derived.kt } @R|Anno|[Types](s = (String(number: ), R|/prop|)) public open override [ResolvedTo(BODY_RESOLVE)] fun getSomething(): R|@R|Anno|(s = (String(type: ), R|/prop|)) kotlin/String| { - ^getSomething String(str).R|kotlin/also|(::R|kotlin/io/println|) + ^getSomething String(str).R|kotlin/also|(String(type: ), R|/prop|)) kotlin/String|>(::R|kotlin/io/println|) } } @@ -178,7 +178,7 @@ FILE: [ResolvedTo(BODY_RESOLVE)] Derived.kt } @R|Anno|[Types](s = (String(number: ), R|/prop|)) public open override [ResolvedTo(BODY_RESOLVE)] fun getSomething(): R|@R|Anno|(s = (String(type: ), R|/prop|)) kotlin/String| { - ^getSomething String(str).R|kotlin/also|(::R|kotlin/io/println|) + ^getSomething String(str).R|kotlin/also|(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 91527bd819e..401d73fd717 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.FirRegularClass 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 @@ object FirPropertyAccessorsTypesChecker : FirPropertyChecker() { 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 d358fc9f423..9855a3ac261 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 class ConeAttribute> : 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 /** @@ -159,32 +152,6 @@ class ConeAttributes private constructor(attributes: List>) : 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. 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 ee2771a7ece..f02a92fe243 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 @@ 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 } 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 ad0c8814c51..4078015a5d4 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 @@ class EnhancedTypeForWarningAttribute( 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() 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 98aa5a72250..164ab4f7ae1 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 98aa5a72250..164ab4f7ae1 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 98aa5a72250..164ab4f7ae1 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 98aa5a72250..164ab4f7ae1 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 98aa5a72250..164ab4f7ae1 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 98aa5a72250..164ab4f7ae1 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