Support importing non-conventional parameterless Objective-C init

Thus fix #2522 by supporting -[NSOutputStream initToMemory].
This commit is contained in:
Svyatoslav Scherbina
2019-08-05 15:03:42 +03:00
committed by SvyatoslavScherbina
parent e2bef1070f
commit 7efab59bc1
5 changed files with 95 additions and 7 deletions
@@ -25,6 +25,7 @@ fun run() {
testOverrideInit()
testMultipleInheritanceClash()
testClashingWithAny()
testInitWithCustomSelector()
assertEquals(2, ForwardDeclaredEnum.TWO.value)
@@ -374,6 +375,28 @@ fun testClashingWithAny() {
assertTrue(TestClashingWithAny3().equals())
}
fun testInitWithCustomSelector() {
assertFalse(TestInitWithCustomSelector().custom)
assertTrue(TestInitWithCustomSelector(custom = Unit).custom)
val customSubclass: TestInitWithCustomSelector = TestInitWithCustomSelectorSubclass.createCustom()
assertTrue(customSubclass is TestInitWithCustomSelectorSubclass)
assertTrue(customSubclass.custom)
// Test side effect:
var ok = false
assertTrue(TestInitWithCustomSelector(run { ok = true }).custom)
assertTrue(ok)
}
private class TestInitWithCustomSelectorSubclass : TestInitWithCustomSelector {
@OverrideInit constructor(custom: Unit) : super(custom) {
assertSame(Unit, custom)
}
companion object : TestInitWithCustomSelectorMeta()
}
fun nsArrayOf(vararg elements: Any): NSArray = NSMutableArray().apply {
elements.forEach {
this.addObject(it as ObjCObject)