[K/N] KT-58562: Implement frontend checkers for HiddenFromObjC on classes

This commit is contained in:
Sergey Bogolepov
2023-05-19 11:33:17 +00:00
committed by Space Team
parent f3a22e0ac4
commit c57c34525f
14 changed files with 465 additions and 85 deletions
+71 -3
View File
@@ -8,7 +8,7 @@ package kotlin.native
annotation class HidesFromObjC
@HidesFromObjC
@Target(AnnotationTarget.PROPERTY, AnnotationTarget.FUNCTION)
@Target(AnnotationTarget.PROPERTY, AnnotationTarget.FUNCTION, AnnotationTarget.CLASS)
@Retention(AnnotationRetention.BINARY)
annotation class HiddenFromObjC
@@ -21,6 +21,11 @@ annotation class RefinesInSwift
@Retention(AnnotationRetention.BINARY)
public annotation class ShouldRefineInSwift
<!INVALID_REFINES_IN_SWIFT_TARGETS!>@RefinesInSwift<!>
@Target(AnnotationTarget.PROPERTY, AnnotationTarget.FUNCTION, AnnotationTarget.CLASS)
@Retention(AnnotationRetention.BINARY)
public annotation class WrongShouldRefineInSwift
// FILE: plugin.kt
package plugin
@@ -44,12 +49,12 @@ import plugin.PluginShouldRefineInSwift
@Retention(AnnotationRetention.BINARY)
annotation class MyRefinedAnnotationA
<!INVALID_OBJC_REFINEMENT_TARGETS!>@HidesFromObjC<!>
<!INVALID_OBJC_HIDES_TARGETS!>@HidesFromObjC<!>
@Target(AnnotationTarget.PROPERTY, AnnotationTarget.FILE)
@Retention(AnnotationRetention.BINARY)
annotation class MyRefinedAnnotationB
<!INVALID_OBJC_REFINEMENT_TARGETS!>@RefinesInSwift<!>
<!INVALID_REFINES_IN_SWIFT_TARGETS!>@RefinesInSwift<!>
@Retention(AnnotationRetention.BINARY)
annotation class MyRefinedAnnotationC
@@ -132,3 +137,66 @@ interface I {
open class Derived2 : Derived() {
override fun foo() {}
}
@HiddenFromObjC
open class OpenHiddenClass
<!SUBTYPE_OF_HIDDEN_FROM_OBJC!>class InheritsFromOpenHiddenClass : OpenHiddenClass()<!>
@HiddenFromObjC
interface HiddenInterface
interface NotHiddenInterface
<!SUBTYPE_OF_HIDDEN_FROM_OBJC!>class ImplementsHiddenInterface : NotHiddenInterface, HiddenInterface<!>
<!SUBTYPE_OF_HIDDEN_FROM_OBJC!>class InheritsFromOpenHiddenClass2 : NotHiddenInterface, OpenHiddenClass()<!>
@HiddenFromObjC
class OuterHidden {
class Nested {
open class Nested
}
}
<!SUBTYPE_OF_HIDDEN_FROM_OBJC!>class InheritsFromNested : OuterHidden.Nested.Nested()<!>
private class PrivateInheritsFromNested : OuterHidden.Nested.Nested()
internal class InternalInheritsFromNested : OuterHidden.Nested.Nested()
fun produceInstanceOfHidden(): OuterHidden.Nested.Nested {
return object : OuterHidden.Nested.Nested() {}
}
@HiddenFromObjC
enum class MyHiddenEnum {
A,
B,
C
}
@HiddenFromObjC
object MyHiddenObject
sealed class MySealedClass {
@HiddenFromObjC
class MyHiddenSealedVariant : MySealedClass()
class MyPublicVariant : MySealedClass()
}
@HiddenFromObjC
enum class MyHiddenNonTrivialEnum {
A,
B,
C {
override fun sayCheese(): String {
return "Boo :("
}
};
open fun sayCheese(): String {
return "Cheese!"
}
}