Improve support for Objective-C methods clashing with methods of Any (#2914)

This commit is contained in:
SvyatoslavScherbina
2019-04-25 11:29:35 +03:00
committed by GitHub
parent 270a53ac8b
commit cd4e0af034
4 changed files with 123 additions and 1 deletions
@@ -325,7 +325,17 @@ private fun Type.hasUnalignedMembers(): Boolean = when (this) {
// TODO: should the recursive checks be made in indexer when computing `hasUnalignedFields`?
}
private val ObjCMethod.kotlinName: String get() = selector.split(":").first()
private val ObjCMethod.kotlinName: String
get() {
val candidate = selector.split(":").first()
val trimmed = candidate.trimEnd('_')
return if (trimmed == "equals" && parameters.size == 1
|| (trimmed == "hashCode" || trimmed == "toString") && parameters.size == 0) {
candidate + "_"
} else {
candidate
}
}
private val ObjCClassOrProtocol.protocolsWithSupers: Sequence<ObjCProtocol>
get() = this.protocols.asSequence().flatMap { sequenceOf(it) + it.protocolsWithSupers }