I'm having an issue with KotlinPoet and I can't seem to figure it out.
I'm trying to build a statement that uses a number of extension functions and the problem is with the
alloc
extension function. On some classes it manages to "find" and "import" the alloc extension fine, while on other classes it does not, and it generates something like
Box(nativeHeap.kotlinx.cinterop.alloc<,,,>().ptr
.
Any idea what could be the reason for the member not being recognized in some classes but recognized in others? Any tips on debugging this?
You just need to make sure the member can be imported without simple name collisions, otherwise importing will fail and the code generator output will not pass compilation.
v
vbsteven
04/16/2023, 3:25 PM
hmm, I just discovered that the classes that have problems with this also have a generated
alloc
function in the same companion object as the one I am generating my problematic function in.
So it looks like KP is not importing the extension member when it finds a similarly named member in the same Spec, am I doing something wrong by using
MemberName
for extension functions?
e
ephemient
04/16/2023, 3:26 PM
multiple things named
alloc
require manual disambiguation
v
vbsteven
04/16/2023, 3:28 PM
I'm giving the aliased import a try, that will probably solve my issue