diff --git a/backend.native/tests/interop/objc/smoke.h b/backend.native/tests/interop/objc/smoke.h index ea1bb140f17..da1823e752f 100644 --- a/backend.native/tests/interop/objc/smoke.h +++ b/backend.native/tests/interop/objc/smoke.h @@ -154,4 +154,9 @@ NSObject* createNSObject() { @interface TestVarargs (TestVarargsExtension) -(instancetype _Nonnull)initWithFormat:(NSString*)format, ...; +@end; + +@interface TestOverrideInit : NSObject +-(instancetype)initWithValue:(int)value NS_DESIGNATED_INITIALIZER; ++(instancetype)createWithValue:(int)value; @end; \ No newline at end of file diff --git a/backend.native/tests/interop/objc/smoke.kt b/backend.native/tests/interop/objc/smoke.kt index f6b3f5db303..931bbdb04fb 100644 --- a/backend.native/tests/interop/objc/smoke.kt +++ b/backend.native/tests/interop/objc/smoke.kt @@ -22,6 +22,7 @@ fun run() { testBlocks() testCustomRetain() testVarargs() + testOverrideInit() assertEquals(2, ForwardDeclaredEnum.TWO.value) @@ -299,6 +300,14 @@ fun testVarargs() { ) } +fun testOverrideInit() { + assertEquals(42, (TestOverrideInitImpl.createWithValue(42) as TestOverrideInitImpl).value) +} + +class TestOverrideInitImpl @OverrideInit constructor(val value: Int) : TestOverrideInit(value) { + companion object : TestOverrideInitMeta() +} + private class MyException : Throwable() fun nsArrayOf(vararg elements: Any): NSArray = NSMutableArray().apply { diff --git a/backend.native/tests/interop/objc/smoke.m b/backend.native/tests/interop/objc/smoke.m index 9bbcc8d3a34..aa7f078deea 100644 --- a/backend.native/tests/interop/objc/smoke.m +++ b/backend.native/tests/interop/objc/smoke.m @@ -144,4 +144,14 @@ static CustomRetainMethodsImpl* retainedCustomRetainMethodsImpl; return result; } +@end; + +@implementation TestOverrideInit +-(instancetype)initWithValue:(int)value { + return self = [super init]; +} + ++(instancetype)createWithValue:(int)value { + return [[self alloc] initWithValue:value]; +} @end; \ No newline at end of file