diff --git a/backend.native/tests/framework/values/expectedLazy.h b/backend.native/tests/framework/values/expectedLazy.h index 3b5e3682605..ca37c8f08fb 100644 --- a/backend.native/tests/framework/values/expectedLazy.h +++ b/backend.native/tests/framework/values/expectedLazy.h @@ -989,6 +989,11 @@ __attribute__((swift_name("ClassForTypeCheck"))) + (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead"))); @end; +__attribute__((swift_name("InterfaceForTypeCheck"))) +@protocol ValuesInterfaceForTypeCheck +@required +@end; + @interface ValuesEnumeration (ValuesKt) - (ValuesEnumeration *)getAnswer __attribute__((swift_name("getAnswer()"))); @end; @@ -1069,6 +1074,7 @@ __attribute__((swift_name("ValuesKt"))) + (void)warning __attribute__((swift_name("warning()"))) __attribute__((deprecated("warning"))); + (void)gc __attribute__((swift_name("gc()"))); + (BOOL)testClassTypeCheckX:(id)x __attribute__((swift_name("testClassTypeCheck(x:)"))); ++ (BOOL)testInterfaceTypeCheckX:(id)x __attribute__((swift_name("testInterfaceTypeCheck(x:)"))); @property (class, readonly) double dbl __attribute__((swift_name("dbl"))); @property (class, readonly) float flt __attribute__((swift_name("flt"))); @property (class, readonly) int32_t integer __attribute__((swift_name("integer"))); diff --git a/backend.native/tests/framework/values/values.kt b/backend.native/tests/framework/values/values.kt index 7222e341468..83ca982afa1 100644 --- a/backend.native/tests/framework/values/values.kt +++ b/backend.native/tests/framework/values/values.kt @@ -777,4 +777,8 @@ class SharedRefs { open class ClassForTypeCheck -fun testClassTypeCheck(x: Any) = x is ClassForTypeCheck \ No newline at end of file +fun testClassTypeCheck(x: Any) = x is ClassForTypeCheck + +interface InterfaceForTypeCheck + +fun testInterfaceTypeCheck(x: Any) = x is InterfaceForTypeCheck \ No newline at end of file diff --git a/backend.native/tests/framework/values/values.swift b/backend.native/tests/framework/values/values.swift index 60d6403e6ff..3a8dfbdeffc 100644 --- a/backend.native/tests/framework/values/values.swift +++ b/backend.native/tests/framework/values/values.swift @@ -1004,6 +1004,18 @@ func testClassTypeCheck() throws { try assertTrue(ValuesKt.testClassTypeCheck(x: ClassForTypeCheckInheritor())) } +class ClassForInterfaceTypeCheckInheritor1 : InterfaceForTypeCheck { } +class ClassForInterfaceTypeCheckInheritor2 : Base23, InterfaceForTypeCheck { } +class ClassForInterfaceTypeCheckInheritor3 : Base23, ExtendedBase1, InterfaceForTypeCheck { } +class ClassForInterfaceTypeCheck_Fail : Base23 { } + +func testInterfaceTypeCheck() throws { + try assertTrue(ValuesKt.testInterfaceTypeCheck(x: ClassForInterfaceTypeCheckInheritor1())) + try assertTrue(ValuesKt.testInterfaceTypeCheck(x: ClassForInterfaceTypeCheckInheritor2())) + try assertTrue(ValuesKt.testInterfaceTypeCheck(x: ClassForInterfaceTypeCheckInheritor3())) + try assertFalse(ValuesKt.testInterfaceTypeCheck(x: ClassForInterfaceTypeCheck_Fail())) +} + // -------- Execution of the test -------- class ValuesTests : TestProvider { @@ -1054,6 +1066,7 @@ class ValuesTests : TestProvider { TestCase(name: "TestWeakRefs", method: withAutorelease(testWeakRefs)), TestCase(name: "TestSharedRefs", method: withAutorelease(TestSharedRefs().test)), TestCase(name: "TestClassTypeCheck", method: withAutorelease(testClassTypeCheck)), + TestCase(name: "TestInterfaceTypeCheck", method: withAutorelease(testInterfaceTypeCheck)), TestCase(name: "TestGH2931", method: withAutorelease(testGH2931)), ] } diff --git a/backend.native/tests/interop/objc/smoke.kt b/backend.native/tests/interop/objc/smoke.kt index 2e376ee6e46..9c94459475f 100644 --- a/backend.native/tests/interop/objc/smoke.kt +++ b/backend.native/tests/interop/objc/smoke.kt @@ -141,6 +141,8 @@ class MutablePairImpl(first: Int, second: Int) : NSObject(), MutablePairProtocol constructor() : this(123, 321) } +interface Zzz + fun testTypeOps() { assertTrue(99.asAny() is NSNumber) assertTrue(null.asAny() is NSNumber?) @@ -149,6 +151,7 @@ fun testTypeOps() { assertTrue("bar".asAny() is NSString) assertTrue(Foo.asAny() is FooMeta) + assertFalse(Foo.asAny() is Zzz) assertTrue(Foo.asAny() is NSObjectMeta) assertTrue(Foo.asAny() is NSObject) assertFalse(Foo.asAny() is Foo)