diff --git a/backend.native/tests/framework/values/expectedLazy.h b/backend.native/tests/framework/values/expectedLazy.h index e9fa9c0ba66..63bb48e7838 100644 --- a/backend.native/tests/framework/values/expectedLazy.h +++ b/backend.native/tests/framework/values/expectedLazy.h @@ -1030,6 +1030,14 @@ __attribute__((swift_name("GH3525"))) + (instancetype)gH3525 __attribute__((swift_name("init()"))); @end; +__attribute__((objc_subclassing_restricted)) +__attribute__((swift_name("TestStringConversion"))) +@interface ValuesTestStringConversion : ValuesBase +- (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer)); ++ (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead"))); +@property id str __attribute__((swift_name("str"))); +@end; + @interface ValuesEnumeration (ValuesKt) - (ValuesEnumeration *)getAnswer __attribute__((swift_name("getAnswer()"))); @end; diff --git a/backend.native/tests/framework/values/values.kt b/backend.native/tests/framework/values/values.kt index 031f6a3bad4..ce7f8fe2953 100644 --- a/backend.native/tests/framework/values/values.kt +++ b/backend.native/tests/framework/values/values.kt @@ -826,4 +826,8 @@ object GH3525 : GH3525Base() { init { gh3525InitCount++ } +} + +class TestStringConversion { + lateinit var str: Any } \ 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 e07d94fab35..3bd61ac6ad2 100644 --- a/backend.native/tests/framework/values/values.swift +++ b/backend.native/tests/framework/values/values.swift @@ -1077,6 +1077,19 @@ func testGH3525() throws { try assertTrue(gh3525_1 === gh3525_2) } +func testStringConversion() throws { + let test = TestStringConversion() + + let buffer = NSMutableString() + buffer.append("a") + test.str = buffer + buffer.append("b") + + try assertEquals(actual: buffer, expected: "ab") + // Ensure test.str isn't affected by buffer mutation: + try assertEquals(actual: test.str as! NSString, expected: "a") +} + // -------- Execution of the test -------- class ValuesTests : TestProvider { @@ -1132,6 +1145,7 @@ class ValuesTests : TestProvider { TestCase(name: "TestGH3503_2", method: withAutorelease(testGH3503_2)), TestCase(name: "TestGH3503_3", method: withAutorelease(testGH3503_3)), TestCase(name: "TestGH3525", method: withAutorelease(testGH3525)), + TestCase(name: "TestStringConversion", method: withAutorelease(testStringConversion)), // Stress test, must remain the last one: TestCase(name: "TestGH2931", method: withAutorelease(testGH2931)),