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
@@ -68,6 +68,13 @@ private fun ObjCMethod.getKotlinParameters(
stubIrBuilder: StubsBuildingContext,
forConstructorOrFactory: Boolean
): List<FunctionParameterStub> {
if (this.isInit && this.parameters.isEmpty() && this.selector != "init") {
// Create synthetic Unit parameter, just like Swift does in this case:
val parameterName = this.selector.removePrefix("init").removePrefix("With").decapitalize()
return listOf(FunctionParameterStub(parameterName, WrapperStubType(KotlinTypes.unit)))
// Note: this parameter is explicitly handled in compiler.
}
val names = getKotlinParameterNames(forConstructorOrFactory) // TODO: consider refactoring.
val result = mutableListOf<FunctionParameterStub>()