From d6a4a3832e6a662342c77bee8236f3a79d6b4418 Mon Sep 17 00:00:00 2001 From: SvyatoslavScherbina Date: Wed, 17 Jun 2020 14:15:47 +0700 Subject: [PATCH] Add test for https://github.com/JetBrains/kotlin-native/issues/3992 --- .../tests/objcexport/expectedLazy.h | 33 +++++++++++++++++++ .../tests/objcexport/headerWarnings.kt | 11 +++++++ .../tests/objcexport/headerWarnings.swift | 11 +++++++ 3 files changed, 55 insertions(+) diff --git a/backend.native/tests/objcexport/expectedLazy.h b/backend.native/tests/objcexport/expectedLazy.h index f037241b94e..ddf3668ac56 100644 --- a/backend.native/tests/objcexport/expectedLazy.h +++ b/backend.native/tests/objcexport/expectedLazy.h @@ -348,6 +348,39 @@ __attribute__((swift_name("TestIncompatiblePropertyTypeWarning.ClassOverridingIn @property (readonly) KtTestIncompatiblePropertyTypeWarningGeneric *p __attribute__((swift_name("p"))); @end; +__attribute__((objc_subclassing_restricted)) +__attribute__((swift_name("TestGH3992"))) +@interface KtTestGH3992 : KtBase +- (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer)); ++ (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead"))); +@end; + +__attribute__((swift_name("TestGH3992.C"))) +@interface KtTestGH3992C : KtBase +- (instancetype)initWithA:(KtTestGH3992A *)a __attribute__((swift_name("init(a:)"))) __attribute__((objc_designated_initializer)); +@property (readonly) KtTestGH3992A *a __attribute__((swift_name("a"))); +@end; + +__attribute__((objc_subclassing_restricted)) +__attribute__((swift_name("TestGH3992.D"))) +@interface KtTestGH3992D : KtTestGH3992C +- (instancetype)initWithA:(KtTestGH3992B *)a __attribute__((swift_name("init(a:)"))) __attribute__((objc_designated_initializer)); +@property (readonly) KtTestGH3992B *a __attribute__((swift_name("a"))); +@end; + +__attribute__((swift_name("TestGH3992.A"))) +@interface KtTestGH3992A : KtBase +- (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer)); ++ (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead"))); +@end; + +__attribute__((objc_subclassing_restricted)) +__attribute__((swift_name("TestGH3992.B"))) +@interface KtTestGH3992B : KtTestGH3992A +- (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer)); ++ (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead"))); +@end; + __attribute__((objc_subclassing_restricted)) __attribute__((swift_name("Kt35940Kt"))) @interface KtKt35940Kt : KtBase diff --git a/backend.native/tests/objcexport/headerWarnings.kt b/backend.native/tests/objcexport/headerWarnings.kt index 7894eeccd33..2859dfe25ff 100644 --- a/backend.native/tests/objcexport/headerWarnings.kt +++ b/backend.native/tests/objcexport/headerWarnings.kt @@ -16,3 +16,14 @@ class TestIncompatiblePropertyTypeWarning { class ClassOverridingInterfaceWithGenericProperty(override val p: Generic) : InterfaceWithGenericProperty } + +// https://github.com/JetBrains/kotlin-native/issues/3992 +class TestGH3992 { + abstract class C(open val a: A) + + class D(override val a: B) : C(a) + + abstract class A + + class B : A() +} diff --git a/backend.native/tests/objcexport/headerWarnings.swift b/backend.native/tests/objcexport/headerWarnings.swift index afd0064b9d6..7c23c799b82 100644 --- a/backend.native/tests/objcexport/headerWarnings.swift +++ b/backend.native/tests/objcexport/headerWarnings.swift @@ -22,10 +22,21 @@ private func testIncompatiblePropertyType() throws { try assertEquals(actual: pi.value as! String, expected: "cba") } +private func testGH3992() throws { + let d = TestGH3992.D(a: TestGH3992.B()) + let c: TestGH3992.C = d + + let b: TestGH3992.B = d.a + let a: TestGH3992.A = b + + try assertTrue(a is TestGH3992.B) +} + class HeaderWarningsTests : SimpleTestProvider { override init() { super.init() test("TestIncompatiblePropertyType", testIncompatiblePropertyType) + test("TestGH3992", testGH3992) } } \ No newline at end of file