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 00c6dfef6fe..ffa79794fae 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 @@ -470,7 +470,8 @@ fun FirClass<*>.irOrigin(firProvider: FirProvider): IrDeclarationOrigin = when { } fun FirClass<*>.getSamIfAny(): FirSimpleFunction? = - declarations.filterIsInstance().singleOrNull { it.modality == Modality.ABSTRACT } + declarations.filterIsInstance() + .singleOrNull { it.modality == Modality.ABSTRACT && !it.isPublicInObject(checkOnlyName = true) } val IrType.isSamType: Boolean get() { diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/SamResolution.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/SamResolution.kt index dc72d286834..64b9fbb481a 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/SamResolution.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/SamResolution.kt @@ -316,7 +316,7 @@ private fun FirRegularClass.hasMoreThenOneAbstractFunctionOrHasAbstractProperty( // "methods that are members of I that do not have the same signature as any public instance method of the class Object" // It means that if an interface declares `int hashCode()` then the method won't be taken into account when // checking if the interface is SAM. -private fun FirSimpleFunction.isPublicInObject(checkOnlyName: Boolean): Boolean { +fun FirSimpleFunction.isPublicInObject(checkOnlyName: Boolean): Boolean { if (name.asString() !in PUBLIC_METHOD_NAMES_IN_OBJECT) return false if (checkOnlyName) return true diff --git a/compiler/testData/codegen/box/callableReference/function/sortListOfStrings.kt b/compiler/testData/codegen/box/callableReference/function/sortListOfStrings.kt index 0c8403b3844..07735f6b661 100644 --- a/compiler/testData/codegen/box/callableReference/function/sortListOfStrings.kt +++ b/compiler/testData/codegen/box/callableReference/function/sortListOfStrings.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // WITH_RUNTIME // KJS_WITH_FULL_RUNTIME diff --git a/compiler/testData/codegen/box/sam/constructors/comparator.kt b/compiler/testData/codegen/box/sam/constructors/comparator.kt index 1794f5c0e8c..b6425b8e53a 100644 --- a/compiler/testData/codegen/box/sam/constructors/comparator.kt +++ b/compiler/testData/codegen/box/sam/constructors/comparator.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // WITH_RUNTIME // KJS_WITH_FULL_RUNTIME diff --git a/compiler/testData/codegen/box/sam/constructors/nonLiteralComparator.kt b/compiler/testData/codegen/box/sam/constructors/nonLiteralComparator.kt index ef095da46c3..4df997f35f9 100644 --- a/compiler/testData/codegen/box/sam/constructors/nonLiteralComparator.kt +++ b/compiler/testData/codegen/box/sam/constructors/nonLiteralComparator.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // WITH_RUNTIME // KJS_WITH_FULL_RUNTIME