From c898b264baa7a304f9e6da15cce7fd65362ecd00 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Thu, 11 May 2023 11:30:25 +0200 Subject: [PATCH] FIR2IR: fix receiver of value classes method references This commit fixes the receiver of these method in FIR2IR code by removing a particular hack. However, as the consequence of it 2 black box tests become broken in K2. The reason is KT-54952 which is not yet fixed Related to KT-54887 --- .../src/org/jetbrains/kotlin/fir/backend/ConversionUtils.kt | 5 +---- .../callableReferences/equalsHashCodeToString.kt | 1 + .../callableReferences/equalsHashCodeToStringGeneric.kt | 1 + .../ir/irText/firProblems/valueClassEquals.fir.ir.txt | 2 +- .../ir/irText/firProblems/valueClassEquals.fir.kt.txt | 2 +- 5 files changed, 5 insertions(+), 6 deletions(-) diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/ConversionUtils.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/ConversionUtils.kt index 896fb63d97c..a912d66b304 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/ConversionUtils.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/ConversionUtils.kt @@ -243,10 +243,7 @@ private fun FirCallableSymbol<*>.toSymbolForCall( } // Unbound callable reference to member (non-extension) isReference && fir.receiverParameter == null -> { - // TODO: remove runIf with StandardClassIds.Any comparison after fixing ValueClass::equals case (KT-54887) - runIf(containingClassLookupTag()?.classId != StandardClassIds.Any) { - (explicitReceiver as? FirResolvedQualifier)?.toLookupTag(session) - } + (explicitReceiver as? FirResolvedQualifier)?.toLookupTag(session) } else -> null } diff --git a/compiler/testData/codegen/box/inlineClasses/callableReferences/equalsHashCodeToString.kt b/compiler/testData/codegen/box/inlineClasses/callableReferences/equalsHashCodeToString.kt index f9db79a4bd7..df9ff4657ff 100644 --- a/compiler/testData/codegen/box/inlineClasses/callableReferences/equalsHashCodeToString.kt +++ b/compiler/testData/codegen/box/inlineClasses/callableReferences/equalsHashCodeToString.kt @@ -1,6 +1,7 @@ // IGNORE_BACKEND: WASM // WASM_MUTE_REASON: IGNORED_IN_JS // IGNORE_BACKEND: JS, JS_IR, JS_IR_ES6, NATIVE +// IGNORE_BACKEND_K2: JVM_IR // WITH_REFLECT // WITH_STDLIB // WORKS_WHEN_VALUE_CLASS diff --git a/compiler/testData/codegen/box/inlineClasses/callableReferences/equalsHashCodeToStringGeneric.kt b/compiler/testData/codegen/box/inlineClasses/callableReferences/equalsHashCodeToStringGeneric.kt index f36317e6d66..6e9cf65e976 100644 --- a/compiler/testData/codegen/box/inlineClasses/callableReferences/equalsHashCodeToStringGeneric.kt +++ b/compiler/testData/codegen/box/inlineClasses/callableReferences/equalsHashCodeToStringGeneric.kt @@ -1,6 +1,7 @@ // IGNORE_BACKEND: WASM // WASM_MUTE_REASON: IGNORED_IN_JS // IGNORE_BACKEND: JS, JS_IR, JS_IR_ES6, NATIVE +// IGNORE_BACKEND_K2: JVM_IR // WITH_REFLECT // WITH_STDLIB // WORKS_WHEN_VALUE_CLASS diff --git a/compiler/testData/ir/irText/firProblems/valueClassEquals.fir.ir.txt b/compiler/testData/ir/irText/firProblems/valueClassEquals.fir.ir.txt index d7032fd29c0..80b8ab76c13 100644 --- a/compiler/testData/ir/irText/firProblems/valueClassEquals.fir.ir.txt +++ b/compiler/testData/ir/irText/firProblems/valueClassEquals.fir.ir.txt @@ -69,7 +69,7 @@ FILE fqName: fileName:/valueClassEquals.kt PROPERTY name:equals visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:equals type:kotlin.reflect.KFunction2<.Z, kotlin.Any?, kotlin.Boolean> visibility:private [final,static] EXPRESSION_BODY - FUNCTION_REFERENCE 'public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in kotlin.Any' type=kotlin.reflect.KFunction2<.Z, kotlin.Any?, kotlin.Boolean> origin=null reflectionTarget= + FUNCTION_REFERENCE 'public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in .Z' type=kotlin.reflect.KFunction2<.Z, kotlin.Any?, kotlin.Boolean> origin=null reflectionTarget= FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.reflect.KFunction2<.Z, kotlin.Any?, kotlin.Boolean> correspondingProperty: PROPERTY name:equals visibility:public modality:FINAL [val] BLOCK_BODY diff --git a/compiler/testData/ir/irText/firProblems/valueClassEquals.fir.kt.txt b/compiler/testData/ir/irText/firProblems/valueClassEquals.fir.kt.txt index 4224114cef2..4ea0e5665ba 100644 --- a/compiler/testData/ir/irText/firProblems/valueClassEquals.fir.kt.txt +++ b/compiler/testData/ir/irText/firProblems/valueClassEquals.fir.kt.txt @@ -32,6 +32,6 @@ value class Z { } val equals: KFunction2 - field = Any::equals + field = Z::equals get