You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Binder: a KSP function returning a Kotlin class gives a generic _PmObject, not the rendered class proxy #94
A KSP-scanned top-level function returning a Kotlin class reaches Python as a generic _PmObject, not as the rendered class proxy. The class's methods and properties can't be reached from Python. The result is owned, so no handle leaks, but it is untyped.
Evidence (found by the TypedPython #45 test, interpreted and compiled paths alike)
fun tpSample(index: Long, weight: Double): TpSample in ksp-fixtures/app returned <class '__main__._PmObject'> from tpSample(3, 0.5), so isinstance(_, TpSample) was False and '_PmObject' object has no attribute 'weigh' was raised. A TpSample(...) built with the constructor is a proper proxy.
Code path
PythonProxySource.renderOne, the non-suspend body (~line 946), returns owned(entry, "_pm_invoke(...)"). owned() emits _pm_own(result, '<returnTypeName>') whenever ownedTypeOf(entry) is non-null.
_pm_own (in OWNED_HANDLE, ~line 759) always returns _PmObject(_pm_h, _pm_t). It never looks up the class rendered for _pm_t.
Methods (~1264/1275) and static functions (~1304/1315) use the same owned(), so they likely behave the same way. Not observed.
Docs that disagree with the code
python-multiplatform-ksp/.../FragmentScanner.kt:198 (topLevelFunctionEntry) sets returnTypeName, and Model.kt:53 documents it as filled.
PythonProxySource.kt:925 (the ownedTypeOf KDoc) still says KSP supplies none.
Lines 255–256 ("What is still not rendered") say "KSP emits no return type name". They also say wrapping in the rendered class would gain nothing because no rendered class shares a name with a returned type. That no longer holds for KSP.
Done when
A KSP function returning a bound Kotlin class returns an instance of that class's rendered proxy (methods and properties work), with ownership unchanged. A ksp-fixtures test covers a top-level function return and a method return.
Activity
Docs: SPEC U-11 implemented (#94)
b-re-w commentedon Oct 3, 2026
Landed in develop via #111.