[ObjCInterop] Implement @ObjCSignatureOverride

This annotation leads to conflicting overloads error supression,
in case where several function with the same argument types,
but different argument names are inherited from ObjC class.

We need to implement it in both K1 and K2 to make the IDE experience
better.
But the annotation itself wouldn't be available in K1.

    ^KT-61323
This commit is contained in:
Pavel Kunyavskiy
2024-01-18 14:56:57 +01:00
committed by Space Team
parent 77eee0d3fc
commit 6e8a7d4662
30 changed files with 698 additions and 41 deletions
@@ -63,3 +63,21 @@ public annotation class BetaInteropApi
@Retention(AnnotationRetention.BINARY)
@RequiresOptIn(level = RequiresOptIn.Level.ERROR)
public annotation class ExperimentalForeignApi
/**
* Marks functions for which Objective-C rules should be used for determinating whether two functions are conflicting.
*
* Objective-C allows overloads by selector. Such functions can have same types, and differ only by parameter names in Kotlin,
* while it is not generally supported.
*
* This leads to an error, when a Kotlin class attempts to override both versions of a method that is overloaded by names only.
*
* If all such methods are annotated by this annotation, the error would be suppressed.
*
* Annotation is only applicable to overrides of methods coming from Objective-C interop.
*/
@Target(AnnotationTarget.FUNCTION)
@Retention(AnnotationRetention.SOURCE)
@Suppress("NEWER_VERSION_IN_SINCE_KOTLIN")
@SinceKotlin("2.0")
public annotation class ObjCSignatureOverride
@@ -68,9 +68,6 @@ internal inline fun <F> PhaseContext.firFrontend(
metadataCompilationMode = config.metadataKlib,
isCommonSource = isCommonSource,
fileBelongsToModule = fileBelongsToModule,
registerExtraComponents = {
it.register(FirOverrideChecker::class, FirNativeOverrideChecker(it))
},
)
val outputs = sessionsWithSources.map { (session, sources) ->