diff --git a/kotlin-native/backend.native/tests/objcexport/expectedLazy.h b/kotlin-native/backend.native/tests/objcexport/expectedLazy.h index 7114b0e0212..27fb862d28d 100644 --- a/kotlin-native/backend.native/tests/objcexport/expectedLazy.h +++ b/kotlin-native/backend.native/tests/objcexport/expectedLazy.h @@ -2108,35 +2108,20 @@ __attribute__((swift_name("TestInvalidIdentifiers"))) @interface KtTestInvalidIdentifiers : KtBase - (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer)); + (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead"))); -@property (class, readonly, getter=companion) KtTestInvalidIdentifiersCompanion_ *companion __attribute__((swift_name("companion"))); -- (int32_t)a_d_d_1:(int32_t)_1 _2:(int32_t)_2 _3:(int32_t)_3 __attribute__((swift_name("a_d_d(_1:_2:_3:)"))); -@property NSString *_status __attribute__((swift_name("_status"))); +@property (class, readonly, getter=companion) KtTestInvalidIdentifiersCompanionS *companion __attribute__((swift_name("companion"))); +- (int32_t)aSdSdS1:(int32_t)S1 _2:(int32_t)_2 _3:(int32_t)_3 __attribute__((swift_name("aSdSd(S1:_2:_3:)"))); @property (readonly) unichar __ __attribute__((swift_name("__"))); @property (readonly) unichar __ __attribute__((swift_name("__"))); @end; -__attribute__((objc_subclassing_restricted)) -__attribute__((swift_name("TestInvalidIdentifiers._Foo"))) -@interface KtTestInvalidIdentifiers_Foo : 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("TestInvalidIdentifiers.Bar_"))) -@interface KtTestInvalidIdentifiersBar_ : 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("TestInvalidIdentifiers.E"))) @interface KtTestInvalidIdentifiersE : KtKotlinEnum + (instancetype)alloc __attribute__((unavailable)); + (instancetype)allocWithZone:(struct _NSZone *)zone __attribute__((unavailable)); - (instancetype)initWithName:(NSString *)name ordinal:(int32_t)ordinal __attribute__((swift_name("init(name:ordinal:)"))) __attribute__((objc_designated_initializer)) __attribute__((unavailable)); -@property (class, readonly) KtTestInvalidIdentifiersE *_4_ __attribute__((swift_name("_4_"))); -@property (class, readonly) KtTestInvalidIdentifiersE *_5_ __attribute__((swift_name("_5_"))); +@property (class, readonly) KtTestInvalidIdentifiersE *_4s __attribute__((swift_name("_4s"))); +@property (class, readonly) KtTestInvalidIdentifiersE *_5s __attribute__((swift_name("_5s"))); @property (class, readonly) KtTestInvalidIdentifiersE *__ __attribute__((swift_name("__"))); @property (class, readonly) KtTestInvalidIdentifiersE *__ __attribute__((swift_name("__"))); + (KtKotlinArray *)values __attribute__((swift_name("values()"))); @@ -2144,12 +2129,12 @@ __attribute__((swift_name("TestInvalidIdentifiers.E"))) @end; __attribute__((objc_subclassing_restricted)) -__attribute__((swift_name("TestInvalidIdentifiers.Companion_"))) -@interface KtTestInvalidIdentifiersCompanion_ : KtBase +__attribute__((swift_name("TestInvalidIdentifiers.CompanionS"))) +@interface KtTestInvalidIdentifiersCompanionS : KtBase + (instancetype)alloc __attribute__((unavailable)); + (instancetype)allocWithZone:(struct _NSZone *)zone __attribute__((unavailable)); -+ (instancetype)companion_ __attribute__((swift_name("init()"))); -@property (class, readonly, getter=shared) KtTestInvalidIdentifiersCompanion_ *shared __attribute__((swift_name("shared"))); ++ (instancetype)companionS __attribute__((swift_name("init()"))); +@property (class, readonly, getter=shared) KtTestInvalidIdentifiersCompanionS *shared __attribute__((swift_name("shared"))); @property (readonly) int32_t _42 __attribute__((swift_name("_42"))); @end; diff --git a/kotlin-native/backend.native/tests/objcexport/expectedLazyLegacySuspendUnit.h b/kotlin-native/backend.native/tests/objcexport/expectedLazyLegacySuspendUnit.h index 8aa6658cbaa..63763bd82f0 100644 --- a/kotlin-native/backend.native/tests/objcexport/expectedLazyLegacySuspendUnit.h +++ b/kotlin-native/backend.native/tests/objcexport/expectedLazyLegacySuspendUnit.h @@ -2050,35 +2050,20 @@ __attribute__((swift_name("TestInvalidIdentifiers"))) @interface KtTestInvalidIdentifiers : KtBase - (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer)); + (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead"))); -@property (class, readonly, getter=companion) KtTestInvalidIdentifiersCompanion_ *companion __attribute__((swift_name("companion"))); -- (int32_t)a_d_d_1:(int32_t)_1 _2:(int32_t)_2 _3:(int32_t)_3 __attribute__((swift_name("a_d_d(_1:_2:_3:)"))); -@property NSString *_status __attribute__((swift_name("_status"))); +@property (class, readonly, getter=companion) KtTestInvalidIdentifiersCompanionS *companion __attribute__((swift_name("companion"))); +- (int32_t)aSdSdS1:(int32_t)S1 _2:(int32_t)_2 _3:(int32_t)_3 __attribute__((swift_name("aSdSd(S1:_2:_3:)"))); @property (readonly) unichar __ __attribute__((swift_name("__"))); @property (readonly) unichar __ __attribute__((swift_name("__"))); @end; -__attribute__((objc_subclassing_restricted)) -__attribute__((swift_name("TestInvalidIdentifiers._Foo"))) -@interface KtTestInvalidIdentifiers_Foo : 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("TestInvalidIdentifiers.Bar_"))) -@interface KtTestInvalidIdentifiersBar_ : 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("TestInvalidIdentifiers.E"))) @interface KtTestInvalidIdentifiersE : KtKotlinEnum + (instancetype)alloc __attribute__((unavailable)); + (instancetype)allocWithZone:(struct _NSZone *)zone __attribute__((unavailable)); - (instancetype)initWithName:(NSString *)name ordinal:(int32_t)ordinal __attribute__((swift_name("init(name:ordinal:)"))) __attribute__((objc_designated_initializer)) __attribute__((unavailable)); -@property (class, readonly) KtTestInvalidIdentifiersE *_4_ __attribute__((swift_name("_4_"))); -@property (class, readonly) KtTestInvalidIdentifiersE *_5_ __attribute__((swift_name("_5_"))); +@property (class, readonly) KtTestInvalidIdentifiersE *_4s __attribute__((swift_name("_4s"))); +@property (class, readonly) KtTestInvalidIdentifiersE *_5s __attribute__((swift_name("_5s"))); @property (class, readonly) KtTestInvalidIdentifiersE *__ __attribute__((swift_name("__"))); @property (class, readonly) KtTestInvalidIdentifiersE *__ __attribute__((swift_name("__"))); + (KtKotlinArray *)values __attribute__((swift_name("values()"))); @@ -2086,12 +2071,12 @@ __attribute__((swift_name("TestInvalidIdentifiers.E"))) @end; __attribute__((objc_subclassing_restricted)) -__attribute__((swift_name("TestInvalidIdentifiers.Companion_"))) -@interface KtTestInvalidIdentifiersCompanion_ : KtBase +__attribute__((swift_name("TestInvalidIdentifiers.CompanionS"))) +@interface KtTestInvalidIdentifiersCompanionS : KtBase + (instancetype)alloc __attribute__((unavailable)); + (instancetype)allocWithZone:(struct _NSZone *)zone __attribute__((unavailable)); -+ (instancetype)companion_ __attribute__((swift_name("init()"))); -@property (class, readonly, getter=shared) KtTestInvalidIdentifiersCompanion_ *shared __attribute__((swift_name("shared"))); ++ (instancetype)companionS __attribute__((swift_name("init()"))); +@property (class, readonly, getter=shared) KtTestInvalidIdentifiersCompanionS *shared __attribute__((swift_name("shared"))); @property (readonly) int32_t _42 __attribute__((swift_name("_42"))); @end; diff --git a/kotlin-native/backend.native/tests/objcexport/expectedLazyNoGenerics.h b/kotlin-native/backend.native/tests/objcexport/expectedLazyNoGenerics.h index fe88b5eb339..2a473ac7acb 100644 --- a/kotlin-native/backend.native/tests/objcexport/expectedLazyNoGenerics.h +++ b/kotlin-native/backend.native/tests/objcexport/expectedLazyNoGenerics.h @@ -2050,35 +2050,20 @@ __attribute__((swift_name("TestInvalidIdentifiers"))) @interface KtTestInvalidIdentifiers : KtBase - (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer)); + (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead"))); -@property (class, readonly, getter=companion) KtTestInvalidIdentifiersCompanion_ *companion __attribute__((swift_name("companion"))); -- (int32_t)a_d_d_1:(int32_t)_1 _2:(int32_t)_2 _3:(int32_t)_3 __attribute__((swift_name("a_d_d(_1:_2:_3:)"))); -@property NSString *_status __attribute__((swift_name("_status"))); +@property (class, readonly, getter=companion) KtTestInvalidIdentifiersCompanionS *companion __attribute__((swift_name("companion"))); +- (int32_t)aSdSdS1:(int32_t)S1 _2:(int32_t)_2 _3:(int32_t)_3 __attribute__((swift_name("aSdSd(S1:_2:_3:)"))); @property (readonly) unichar __ __attribute__((swift_name("__"))); @property (readonly) unichar __ __attribute__((swift_name("__"))); @end; -__attribute__((objc_subclassing_restricted)) -__attribute__((swift_name("TestInvalidIdentifiers._Foo"))) -@interface KtTestInvalidIdentifiers_Foo : 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("TestInvalidIdentifiers.Bar_"))) -@interface KtTestInvalidIdentifiersBar_ : 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("TestInvalidIdentifiers.E"))) @interface KtTestInvalidIdentifiersE : KtKotlinEnum + (instancetype)alloc __attribute__((unavailable)); + (instancetype)allocWithZone:(struct _NSZone *)zone __attribute__((unavailable)); - (instancetype)initWithName:(NSString *)name ordinal:(int32_t)ordinal __attribute__((swift_name("init(name:ordinal:)"))) __attribute__((objc_designated_initializer)) __attribute__((unavailable)); -@property (class, readonly) KtTestInvalidIdentifiersE *_4_ __attribute__((swift_name("_4_"))); -@property (class, readonly) KtTestInvalidIdentifiersE *_5_ __attribute__((swift_name("_5_"))); +@property (class, readonly) KtTestInvalidIdentifiersE *_4s __attribute__((swift_name("_4s"))); +@property (class, readonly) KtTestInvalidIdentifiersE *_5s __attribute__((swift_name("_5s"))); @property (class, readonly) KtTestInvalidIdentifiersE *__ __attribute__((swift_name("__"))); @property (class, readonly) KtTestInvalidIdentifiersE *__ __attribute__((swift_name("__"))); + (KtKotlinArray *)values __attribute__((swift_name("values()"))); @@ -2086,12 +2071,12 @@ __attribute__((swift_name("TestInvalidIdentifiers.E"))) @end; __attribute__((objc_subclassing_restricted)) -__attribute__((swift_name("TestInvalidIdentifiers.Companion_"))) -@interface KtTestInvalidIdentifiersCompanion_ : KtBase +__attribute__((swift_name("TestInvalidIdentifiers.CompanionS"))) +@interface KtTestInvalidIdentifiersCompanionS : KtBase + (instancetype)alloc __attribute__((unavailable)); + (instancetype)allocWithZone:(struct _NSZone *)zone __attribute__((unavailable)); -+ (instancetype)companion_ __attribute__((swift_name("init()"))); -@property (class, readonly, getter=shared) KtTestInvalidIdentifiersCompanion_ *shared __attribute__((swift_name("shared"))); ++ (instancetype)companionS __attribute__((swift_name("init()"))); +@property (class, readonly, getter=shared) KtTestInvalidIdentifiersCompanionS *shared __attribute__((swift_name("shared"))); @property (readonly) int32_t _42 __attribute__((swift_name("_42"))); @end; diff --git a/kotlin-native/backend.native/tests/objcexport/values.kt b/kotlin-native/backend.native/tests/objcexport/values.kt index e3c7fb94fd3..5f418e8b617 100644 --- a/kotlin-native/backend.native/tests/objcexport/values.kt +++ b/kotlin-native/backend.native/tests/objcexport/values.kt @@ -579,25 +579,20 @@ class TestClashesImpl : TestClashes1, TestClashes2 { } class TestInvalidIdentifiers { - class `$Foo` - class `Bar$` - - fun `a$d$d`(`$1`: Int, `2`: Int, `3`: Int): Int = `$1` + `2` + `3` - - var `$status`: String = "" + fun `aSdSd`(`S1`: Int, `2`: Int, `3`: Int): Int = `S1` + `2` + `3` enum class E(val value: Int) { - `4$`(4), - `5$`(5), + `4S`(4), + `5S`(5), `_`(6), `__`(7) } - companion object `Companion$` { + companion object `CompanionS` { val `42` = 42 } - val `$` = '$' + val `__` = '_' val `_` = '_' } diff --git a/kotlin-native/backend.native/tests/objcexport/values.swift b/kotlin-native/backend.native/tests/objcexport/values.swift index 89e4f478923..b7745306fd7 100644 --- a/kotlin-native/backend.native/tests/objcexport/values.swift +++ b/kotlin-native/backend.native/tests/objcexport/values.swift @@ -736,22 +736,16 @@ func testClashes() throws { func testInvalidIdentifiers() throws { let test = TestInvalidIdentifiers() - try assertTrue(TestInvalidIdentifiers._Foo() is TestInvalidIdentifiers._Foo) - try assertFalse(TestInvalidIdentifiers.Bar_() is TestInvalidIdentifiers._Foo) + try assertEquals(actual: 42, expected: test.aSdSd(S1: 13, _2: 14, _3: 15)) - try assertEquals(actual: 42, expected: test.a_d_d(_1: 13, _2: 14, _3: 15)) - - test._status = "OK" - try assertEquals(actual: "OK", expected: test._status) - - try assertEquals(actual: TestInvalidIdentifiers.E._4_.value, expected: 4) - try assertEquals(actual: TestInvalidIdentifiers.E._5_.value, expected: 5) + try assertEquals(actual: TestInvalidIdentifiers.E._4s.value, expected: 4) + try assertEquals(actual: TestInvalidIdentifiers.E._5s.value, expected: 5) try assertEquals(actual: TestInvalidIdentifiers.E.__.value, expected: 6) try assertEquals(actual: TestInvalidIdentifiers.E.___.value, expected: 7) - try assertEquals(actual: TestInvalidIdentifiers.Companion_()._42, expected: 42) + try assertEquals(actual: TestInvalidIdentifiers.CompanionS()._42, expected: 42) - try assertEquals(actual: Set([test.__, test.___]), expected: Set(["$".utf16.first, "_".utf16.first])) + try assertEquals(actual: Set([test.__, test.___]), expected: Set(["_".utf16.first, "_".utf16.first])) } class ImplementingHiddenSubclass : TestDeprecation.ImplementingHidden {