Fix property clash when producing framework
This commit is contained in:
committed by
SvyatoslavScherbina
parent
87396c6caf
commit
0831ca7e87
+4
@@ -802,6 +802,10 @@ private fun ObjCExportMapper.canHaveSameName(first: PropertyDescriptor, second:
|
||||
return false
|
||||
}
|
||||
|
||||
if (first.name != second.name) {
|
||||
return false
|
||||
}
|
||||
|
||||
return bridgePropertyType(first) == bridgePropertyType(second)
|
||||
}
|
||||
|
||||
|
||||
@@ -571,6 +571,28 @@ __attribute__((swift_name("TestSR10177Workaround")))
|
||||
@required
|
||||
@end;
|
||||
|
||||
__attribute__((swift_name("TestClashes1")))
|
||||
@protocol ValuesTestClashes1
|
||||
@required
|
||||
@property (readonly) int32_t clashingProperty __attribute__((swift_name("clashingProperty")));
|
||||
@end;
|
||||
|
||||
__attribute__((swift_name("TestClashes2")))
|
||||
@protocol ValuesTestClashes2
|
||||
@required
|
||||
@property (readonly) id clashingProperty __attribute__((swift_name("clashingProperty")));
|
||||
@property (readonly) id clashingProperty_ __attribute__((swift_name("clashingProperty_")));
|
||||
@end;
|
||||
|
||||
__attribute__((objc_subclassing_restricted))
|
||||
__attribute__((swift_name("TestClashesImpl")))
|
||||
@interface ValuesTestClashesImpl : KotlinBase <ValuesTestClashes1, ValuesTestClashes2>
|
||||
- (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer));
|
||||
+ (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead")));
|
||||
@property (readonly) int32_t clashingProperty __attribute__((swift_name("clashingProperty")));
|
||||
@property (readonly) ValuesInt *clashingProperty_ __attribute__((swift_name("clashingProperty_")));
|
||||
@end;
|
||||
|
||||
@interface ValuesEnumeration (ValuesKt)
|
||||
- (ValuesEnumeration *)getAnswer __attribute__((swift_name("getAnswer()")));
|
||||
@end;
|
||||
|
||||
@@ -450,4 +450,21 @@ abstract class ForwardC1 {
|
||||
abstract fun getForwardC2(): ForwardC2
|
||||
}
|
||||
|
||||
interface TestSR10177Workaround
|
||||
interface TestSR10177Workaround
|
||||
|
||||
interface TestClashes1 {
|
||||
val clashingProperty: Int
|
||||
}
|
||||
|
||||
interface TestClashes2 {
|
||||
val clashingProperty: Any
|
||||
val clashingProperty_: Any
|
||||
}
|
||||
|
||||
class TestClashesImpl : TestClashes1, TestClashes2 {
|
||||
override val clashingProperty: Int
|
||||
get() = 1
|
||||
|
||||
override val clashingProperty_: Int
|
||||
get() = 2
|
||||
}
|
||||
|
||||
@@ -613,6 +613,16 @@ func testSR10177Workaround() throws {
|
||||
try assertTrue(String(describing: test).contains("TestSR10177WorkaroundDerived"))
|
||||
}
|
||||
|
||||
func testClashes() throws {
|
||||
let test = TestClashesImpl()
|
||||
let test1: TestClashes1 = test
|
||||
let test2: TestClashes2 = test
|
||||
|
||||
try assertEquals(actual: 1, expected: test1.clashingProperty)
|
||||
try assertEquals(actual: 1, expected: test2.clashingProperty_ as! Int32)
|
||||
try assertEquals(actual: 2, expected: test2.clashingProperty__ as! Int32)
|
||||
}
|
||||
|
||||
// See https://github.com/JetBrains/kotlin-native/issues/2931
|
||||
func testGH2931() throws {
|
||||
for i in 0..<50000 {
|
||||
@@ -678,6 +688,7 @@ class ValuesTests : TestProvider {
|
||||
TestCase(name: "TestGH2959", method: withAutorelease(testGH2959)),
|
||||
TestCase(name: "TestKClass", method: withAutorelease(testKClass)),
|
||||
TestCase(name: "TestSR10177Workaround", method: withAutorelease(testSR10177Workaround)),
|
||||
TestCase(name: "TestClashes", method: withAutorelease(testClashes)),
|
||||
TestCase(name: "TestGH2931", method: withAutorelease(testGH2931)),
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user