Skip to content

Commit c9ab9db

Browse files
SvyatoslavScherbinaSpace Team
authored andcommitted
[K/N][tests] Add a reproducer for KT-85399
This commit adds a test that is basically a simplified version of the code reported by the user in KT-85399, using Objective-C code instead of `@objc` Swift. (cherry picked from commit bef2b50)
1 parent 502e844 commit c9ab9db

1 file changed

Lines changed: 53 additions & 0 deletions

File tree

  • native/native.tests/testData/codegen/cinterop/objc
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// TARGET_BACKEND: NATIVE
2+
// DISABLE_NATIVE: isAppleTarget=false
3+
4+
// KT-85399
5+
// IGNORE_NATIVE: optimizationMode=DEBUG
6+
// IGNORE_NATIVE: optimizationMode=NO
7+
8+
// MODULE: cinterop
9+
// FILE: lib.def
10+
language = Objective-C
11+
headers = lib.h
12+
13+
// FILE: lib.h
14+
#import <Foundation/Foundation.h>
15+
16+
@protocol AService <NSObject>
17+
@end
18+
19+
@interface AServiceImpl : NSObject <AService>
20+
@end
21+
22+
@interface ServiceModule : NSObject
23+
@property (nonatomic, strong) Class<AService> _Nonnull aService;
24+
@end
25+
26+
// FILE: lib.m
27+
#import "lib.h"
28+
29+
@implementation AServiceImpl
30+
@end
31+
32+
@implementation ServiceModule
33+
- (instancetype)init {
34+
self = [super init];
35+
if (self) {
36+
_aService = [AServiceImpl class];
37+
}
38+
return self;
39+
}
40+
@end
41+
42+
// MODULE: main(cinterop)
43+
// FILE: main.kt
44+
@file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
45+
46+
import lib.*
47+
48+
fun box(): String {
49+
val module = ServiceModule()
50+
val service = module.aService
51+
52+
return if (service is AServiceProtocolMeta) "OK" else "FAIL: $service"
53+
}

0 commit comments

Comments
 (0)