diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/SuperCalls.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/SuperCalls.kt index 02a97a20dde..4e3a683cc93 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/SuperCalls.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/SuperCalls.kt @@ -36,12 +36,13 @@ fun BodyResolveComponents.findTypesForSuperCandidates( containingCall: FirQualifiedAccess, ): Collection { val supertypes = superTypeRefs.map { (it as FirResolvedTypeRef).type } - if (supertypes.size <= 1) return supertypes + val isMethodOfAny = containingCall is FirFunctionCall && isCallingMethodOfAny(containingCall) + if (supertypes.size <= 1 && !isMethodOfAny) return supertypes return when (containingCall) { is FirFunctionCall -> { val calleeName = containingCall.calleeReference.name - if (isCallingMethodOfAny(containingCall)) { + if (isMethodOfAny) { resolveSupertypesForMethodOfAny(supertypes, calleeName) } else { resolveSupertypesByCalleeName(supertypes, calleeName) diff --git a/compiler/testData/diagnostics/tests/thisAndSuper/unqualifiedSuper/withMethodOfAnyOverridenInInterface.fir.kt b/compiler/testData/diagnostics/tests/thisAndSuper/unqualifiedSuper/withMethodOfAnyOverridenInInterface.fir.kt deleted file mode 100644 index 209e68c9f15..00000000000 --- a/compiler/testData/diagnostics/tests/thisAndSuper/unqualifiedSuper/withMethodOfAnyOverridenInInterface.fir.kt +++ /dev/null @@ -1,8 +0,0 @@ -interface IWithToString { - override fun toString(): String -} - -class A : IWithToString { - // Should be Any#toString(), even though IWithToString defines an abstract toString. - override fun toString(): String = super.toString() -} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/thisAndSuper/unqualifiedSuper/withMethodOfAnyOverridenInInterface.kt b/compiler/testData/diagnostics/tests/thisAndSuper/unqualifiedSuper/withMethodOfAnyOverridenInInterface.kt index ba5f4f70298..38c2975daef 100644 --- a/compiler/testData/diagnostics/tests/thisAndSuper/unqualifiedSuper/withMethodOfAnyOverridenInInterface.kt +++ b/compiler/testData/diagnostics/tests/thisAndSuper/unqualifiedSuper/withMethodOfAnyOverridenInInterface.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL interface IWithToString { override fun toString(): String }