[klib] Fix serialization of missing annotations

^KT-42490
^KT-44625
This commit is contained in:
Pavel Kunyavskiy
2022-12-12 17:27:41 +01:00
committed by Space Team
parent 90d702ed27
commit 17e9a6a781
21 changed files with 526 additions and 106 deletions
@@ -1293,7 +1293,7 @@ __attribute__((swift_name("MySwiftArray")))
__attribute__((swift_name("ObjCNameI1")))
@protocol KtObjCNameI1
@required
- (int32_t)someOtherFunction:(int32_t)receiver otherParam:(int32_t)param __attribute__((swift_name("someOtherFunction(_:otherParam:)")));
- (int32_t)someOtherFunctionReceiver:(int32_t)receiver otherParam:(int32_t)param __attribute__((swift_name("someOtherFunction(receiver:otherParam:)")));
@property (readonly) int32_t someOtherValue __attribute__((swift_name("someOtherValue")));
@end
@@ -1302,7 +1302,7 @@ __attribute__((swift_name("SwiftNameC2")))
@interface KtObjCNameC2 : KtBase <KtObjCNameI1>
- (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer));
+ (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead")));
- (int32_t)someOtherFunction:(int32_t)receiver otherParam:(int32_t)param __attribute__((swift_name("someOtherFunction(_:otherParam:)")));
- (int32_t)someOtherFunctionReceiver:(int32_t)receiver otherParam:(int32_t)param __attribute__((swift_name("someOtherFunction(receiver:otherParam:)")));
@property int32_t someOtherValue __attribute__((swift_name("someOtherValue")));
@end
@@ -1342,7 +1342,7 @@ __attribute__((swift_name("ObjCNameC4")))
@interface KtObjCNameC4 : KtBase
- (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer));
+ (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead")));
- (int32_t)foo:(int32_t)receiver objCParam:(int32_t)param __attribute__((swift_name("foo(_:objCParam:)")));
- (int32_t)fooObjCReceiver:(int32_t)receiver objCParam:(int32_t)param __attribute__((swift_name("foo(objCReceiver:objCParam:)")));
@end
__attribute__((objc_subclassing_restricted))
@@ -1379,7 +1379,7 @@ __attribute__((swift_name("ObjCNameSwiftEnum.Companion")))
__attribute__((objc_subclassing_restricted))
__attribute__((swift_name("ObjCNameBKt")))
@interface KtObjCNameBKt : KtBase
+ (int32_t)getSomeValue:(id<KtObjCNameI1>)receiver __attribute__((swift_name("getSomeValue(_:)")));
+ (int32_t)getSomeValueOf:(id<KtObjCNameI1>)receiver __attribute__((swift_name("getSomeValue(of:)")));
@end
__attribute__((swift_name("OverrideKotlinMethods2")))
@@ -1228,7 +1228,7 @@ __attribute__((swift_name("MySwiftArray")))
__attribute__((swift_name("ObjCNameI1")))
@protocol KtObjCNameI1
@required
- (int32_t)someOtherFunction:(int32_t)receiver otherParam:(int32_t)param __attribute__((swift_name("someOtherFunction(_:otherParam:)")));
- (int32_t)someOtherFunctionReceiver:(int32_t)receiver otherParam:(int32_t)param __attribute__((swift_name("someOtherFunction(receiver:otherParam:)")));
@property (readonly) int32_t someOtherValue __attribute__((swift_name("someOtherValue")));
@end
@@ -1237,7 +1237,7 @@ __attribute__((swift_name("SwiftNameC2")))
@interface KtObjCNameC2 : KtBase <KtObjCNameI1>
- (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer));
+ (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead")));
- (int32_t)someOtherFunction:(int32_t)receiver otherParam:(int32_t)param __attribute__((swift_name("someOtherFunction(_:otherParam:)")));
- (int32_t)someOtherFunctionReceiver:(int32_t)receiver otherParam:(int32_t)param __attribute__((swift_name("someOtherFunction(receiver:otherParam:)")));
@property int32_t someOtherValue __attribute__((swift_name("someOtherValue")));
@end
@@ -1277,7 +1277,7 @@ __attribute__((swift_name("ObjCNameC4")))
@interface KtObjCNameC4 : KtBase
- (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer));
+ (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead")));
- (int32_t)foo:(int32_t)receiver objCParam:(int32_t)param __attribute__((swift_name("foo(_:objCParam:)")));
- (int32_t)fooObjCReceiver:(int32_t)receiver objCParam:(int32_t)param __attribute__((swift_name("foo(objCReceiver:objCParam:)")));
@end
__attribute__((objc_subclassing_restricted))
@@ -1314,7 +1314,7 @@ __attribute__((swift_name("ObjCNameSwiftEnum.Companion")))
__attribute__((objc_subclassing_restricted))
__attribute__((swift_name("ObjCNameBKt")))
@interface KtObjCNameBKt : KtBase
+ (int32_t)getSomeValue:(id<KtObjCNameI1>)receiver __attribute__((swift_name("getSomeValue(_:)")));
+ (int32_t)getSomeValueOf:(id<KtObjCNameI1>)receiver __attribute__((swift_name("getSomeValue(of:)")));
@end
__attribute__((swift_name("OverrideKotlinMethods2")))
@@ -1228,7 +1228,7 @@ __attribute__((swift_name("MySwiftArray")))
__attribute__((swift_name("ObjCNameI1")))
@protocol KtObjCNameI1
@required
- (int32_t)someOtherFunction:(int32_t)receiver otherParam:(int32_t)param __attribute__((swift_name("someOtherFunction(_:otherParam:)")));
- (int32_t)someOtherFunctionReceiver:(int32_t)receiver otherParam:(int32_t)param __attribute__((swift_name("someOtherFunction(receiver:otherParam:)")));
@property (readonly) int32_t someOtherValue __attribute__((swift_name("someOtherValue")));
@end
@@ -1237,7 +1237,7 @@ __attribute__((swift_name("SwiftNameC2")))
@interface KtObjCNameC2 : KtBase <KtObjCNameI1>
- (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer));
+ (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead")));
- (int32_t)someOtherFunction:(int32_t)receiver otherParam:(int32_t)param __attribute__((swift_name("someOtherFunction(_:otherParam:)")));
- (int32_t)someOtherFunctionReceiver:(int32_t)receiver otherParam:(int32_t)param __attribute__((swift_name("someOtherFunction(receiver:otherParam:)")));
@property int32_t someOtherValue __attribute__((swift_name("someOtherValue")));
@end
@@ -1277,7 +1277,7 @@ __attribute__((swift_name("ObjCNameC4")))
@interface KtObjCNameC4 : KtBase
- (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer));
+ (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead")));
- (int32_t)foo:(int32_t)receiver objCParam:(int32_t)param __attribute__((swift_name("foo(_:objCParam:)")));
- (int32_t)fooObjCReceiver:(int32_t)receiver objCParam:(int32_t)param __attribute__((swift_name("foo(objCReceiver:objCParam:)")));
@end
__attribute__((objc_subclassing_restricted))
@@ -1314,7 +1314,7 @@ __attribute__((swift_name("ObjCNameSwiftEnum.Companion")))
__attribute__((objc_subclassing_restricted))
__attribute__((swift_name("ObjCNameBKt")))
@interface KtObjCNameBKt : KtBase
+ (int32_t)getSomeValue:(id<KtObjCNameI1>)receiver __attribute__((swift_name("getSomeValue(_:)")));
+ (int32_t)getSomeValueOf:(id<KtObjCNameI1>)receiver __attribute__((swift_name("getSomeValue(of:)")));
@end
__attribute__((swift_name("OverrideKotlinMethods2")))
@@ -17,7 +17,7 @@ private func testObjCNameParameterNames() throws {
private func testObjCNameReceiverName() throws {
let object = SwiftNameC2()
try assertEquals(actual: ObjCNameBKt.getSomeValue(object), expected: 0)
try assertEquals(actual: ObjCNameBKt.getSomeValue(of: object), expected: 0)
}
private func testObjCNameMySwiftArray() throws {
@@ -31,8 +31,8 @@ private func testObjCNameOverrides() throws {
try assertEquals(actual: object.someOtherValue, expected: 0)
object.someOtherValue = 1
try assertEquals(actual: object.someOtherValue, expected: 1)
try assertEquals(actual: object.someOtherFunction(2, otherParam: 4), expected: 8)
try assertEquals(actual: ObjCNameC4().foo(3, objCParam: 5), expected: 15)
try assertEquals(actual: object.someOtherFunction(receiver: 2, otherParam: 4), expected: 8)
try assertEquals(actual: ObjCNameC4().foo(objCReceiver: 3, objCParam: 5), expected: 15)
}
private func testObjCNameNestedClass() throws {
@@ -29,12 +29,10 @@ interface ObjCNameI1 {
@ObjCName("someOtherValue")
val someValue: Int
@ObjCName("someOtherFunction")
// KT-53317
fun /* @receiver:ObjCName("receiver") */ Int.someFunction(@ObjCName("otherParam") param: Int): Int
fun @receiver:ObjCName("receiver") Int.someFunction(@ObjCName("otherParam") param: Int): Int
}
// KT-53317
fun /* @receiver:ObjCName("of") */ ObjCNameI1.getSomeValue(): Int = someValue
fun @receiver:ObjCName("of") ObjCNameI1.getSomeValue(): Int = someValue
@ObjCName(swiftName = "SwiftNameC2")
class ObjCNameC2: ObjCNameI1 {
@@ -61,8 +59,7 @@ class ObjCNameC3 {
}
private interface ObjCNameI2 {
// KT-53317
fun /* @receiver:ObjCName("objCReceiver") */ Int.foo(@ObjCName("objCParam") param: Int): Int
fun @receiver:ObjCName("objCReceiver") Int.foo(@ObjCName("objCParam") param: Int): Int
}
class ObjCNameC4: ObjCNameI2 {