Skip to content

Commit

Permalink
Fix collision of types and parameter name in Apinotes for extensions.
Browse files Browse the repository at this point in the history
  • Loading branch information
FilipDolnik committed Nov 13, 2023
1 parent b925411 commit 49f60b0
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion SKIE/acceptance-tests
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,17 @@ val OirClass.superClass: OirClass?
fun OirClass.renderForwardDeclaration(): String =
if (typeParameters.isEmpty()) name else "$name<${typeParameters.joinToString(", ") { it.name }}>"

val OirClass.functions: List<OirFunction>
val OirClass.memberFunctions: List<OirFunction>
get() = callableDeclarations.filterIsInstance<OirFunction>()

val OirClass.constructors: List<OirConstructor>
get() = callableDeclarations.filterIsInstance<OirConstructor>()

val OirClass.simpleFunctions: List<OirSimpleFunction>
val OirClass.memberSimpleFunctions: List<OirSimpleFunction>
get() = callableDeclarations.filterIsInstance<OirSimpleFunction>()

val OirClass.allFunctions: List<OirFunction>
get() = callableDeclarationsIncludingExtensions.filterIsInstance<OirFunction>()

val OirClass.allSimpleFunctions: List<OirSimpleFunction>
get() = callableDeclarationsIncludingExtensions.filterIsInstance<OirSimpleFunction>()
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class CreateOirMembersPhase(
}

private fun getOirCallableDeclarationParent(kirCallableDeclaration: KirCallableDeclaration<*>): OirCallableDeclarationParent =
if (kirCallableDeclaration.origin == KirCallableDeclaration.Origin.Extension && kirCallableDeclaration.owner.kind != KirClass.Kind.Interface) {
if (kirCallableDeclaration.origin == KirCallableDeclaration.Origin.Extension && kirCallableDeclaration.owner.kind != KirClass.Kind.File) {
getOrCreateExtension(kirCallableDeclaration.owner.oirClass)
} else {
kirCallableDeclaration.owner.oirClass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import co.touchlab.skie.oir.element.OirFunction
import co.touchlab.skie.oir.element.OirSimpleFunction
import co.touchlab.skie.oir.element.OirTypeDef
import co.touchlab.skie.oir.element.OirVisibility
import co.touchlab.skie.oir.element.functions
import co.touchlab.skie.oir.element.allFunctions
import co.touchlab.skie.oir.element.memberFunctions
import co.touchlab.skie.oir.type.BlockPointerOirType
import co.touchlab.skie.oir.type.DeclaredOirType
import co.touchlab.skie.oir.type.NonNullReferenceOirType
import co.touchlab.skie.oir.type.NullableReferenceOirType
import co.touchlab.skie.oir.type.OirType
import co.touchlab.skie.oir.type.PointerOirType
Expand Down Expand Up @@ -39,7 +39,7 @@ class FixOirFunctionSignaturesForApiNotesPhase(
}

private fun fixFunctionSignatures(oirClass: OirClass) {
oirClass.functions.forEach {
oirClass.allFunctions.forEach {
fixFunctionSignature(it)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package co.touchlab.skie.phases.other

import co.touchlab.skie.oir.element.OirSimpleFunction
import co.touchlab.skie.oir.element.copyValueParametersFrom
import co.touchlab.skie.oir.element.simpleFunctions
import co.touchlab.skie.oir.element.memberSimpleFunctions
import co.touchlab.skie.phases.SirPhase
import co.touchlab.skie.sir.element.SirVisibility
import co.touchlab.skie.sir.element.copyValueParametersFrom
Expand All @@ -16,7 +16,7 @@ object FixDuplicatedOverridenFunctionsPhase : SirPhase {
context(SirPhase.Context)
override fun execute() {
oirProvider.allKotlinClassesAndProtocols
.flatMap { it.simpleFunctions }
.flatMap { it.memberSimpleFunctions }
.forEach {
fixDuplicates(it)
}
Expand Down

0 comments on commit 49f60b0

Please sign in to comment.