Skip to content

Commit 7cf51ea

Browse files
committed
Fix collision of types and parameter name in Apinotes for complex optional types.
1 parent 49f60b0 commit 7cf51ea

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

SKIE/compiler/kotlin-plugin/src/kgp_common/kotlin/co/touchlab/skie/phases/oir/FixOirFunctionSignaturesForApiNotesPhase.kt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import co.touchlab.skie.oir.element.OirSimpleFunction
66
import co.touchlab.skie.oir.element.OirTypeDef
77
import co.touchlab.skie.oir.element.OirVisibility
88
import co.touchlab.skie.oir.element.allFunctions
9-
import co.touchlab.skie.oir.element.memberFunctions
109
import co.touchlab.skie.oir.type.BlockPointerOirType
1110
import co.touchlab.skie.oir.type.DeclaredOirType
11+
import co.touchlab.skie.oir.type.NonNullReferenceOirType
1212
import co.touchlab.skie.oir.type.NullableReferenceOirType
1313
import co.touchlab.skie.oir.type.OirType
1414
import co.touchlab.skie.oir.type.PointerOirType
@@ -73,7 +73,13 @@ class FixOirFunctionSignaturesForApiNotesPhase(
7373
}
7474
is TypeParameterUsageOirType -> this
7575
is SpecialReferenceOirType -> substituteLeafType(reservedIdentifiers)
76-
is NullableReferenceOirType -> substituteLeafType(reservedIdentifiers)
76+
is NullableReferenceOirType -> {
77+
when (val innerType = nonNullType.substituteReservedIdentifiers(reservedIdentifiers)) {
78+
is NonNullReferenceOirType -> NullableReferenceOirType(innerType)
79+
is TypeDefOirType -> getOrCreateTypeDef(this).toType(innerType.typeArguments)
80+
else -> error("Unexpected inner type: $innerType")
81+
}
82+
}
7783
is PointerOirType -> copy(pointee = pointee.substituteReservedIdentifiers(reservedIdentifiers))
7884
is PrimitiveOirType, VoidOirType -> substituteLeafType(reservedIdentifiers)
7985
is TypeDefOirType -> {

0 commit comments

Comments
 (0)