Skip to content

Walker: bind generic functions and member properties (mutableStateOf, MutableState.value) #38

Closed

Description

@b-re-w

Found while landing #18. pythonx-compose's declarative state (state() / .value, thisisthepy/pythonx-compose#11) needs androidx.compose.runtime.mutableStateOf and MutableState.value from Python. Today:

  1. any declaration mentioning a type parameter is declined (resolveKotlinBoundary / renderKotlinTypeName accept only class classifiers), so mutableStateOf<T> cannot bind;
  2. the walker emits only FUNCTION and STATIC_GETTER entries (ArtifactScanner keeps ACC_STATIC methods), so no instance member properties;
  3. the binding layer's _attach installs methods only, never data descriptors, and looks at the exact declared type only.

Decided (coordinator), Kotlin names only:

  • Walker: substitute Any? for unbounded, non-reified function type parameters; decline bounded or reified ones.
  • Walker: bind public, non-extension, non-@composable member properties of public classes/interfaces as GETTER/SETTER entries (Owner.prop / Owner.prop=); setters only when all class type parameters are unbounded. Exclude GETTER/SETTER from the constructor-prefix collision rule and from overload disambiguation.
  • Binding layer: index GETTER/SETTER by owner type; _attach installs property(fget, fset) with supertype lookup.
  • Stubs: typed properties (coordinate with Stubs: emit proxy classes with typed members instead of int handles #31).
  • Fixture: include SnapshotStateKt plus State/MutableState; switch PythonContentRenderTest from the KSP writeRoot stand-in to state.value = Root.

Risks to check explicitly: new generic bindings joining existing overload sets and changing mangled names tests rely on; table size growth over androidx.compose.ui (report before/after entry counts); the artifact fixture's "every table key is stubbed" invariant.

Completion: Python creates mutableStateOf(None), the host's PythonContent reads it, Python writes .value and the next frame shows the new root; all fixture modules and desktopTest green; entry-count delta reported.

Activity

  1. b-re-w commented on Oct 2, 2026

    @b-re-w
    MemberAuthor

    Scope addition (from #37): material-icons' Icons.Default.Add is a top-level extension property (AddKt.getAdd(Icons$Filled)). ArtifactScanner.scanClassNode reads only kmPackage.functions, never properties, so no getter is bound on the Icons.Filled receiver. #38 therefore also covers extension-property getters: walker binds them with a property-read body, the binding layer serves them as a value on attribute read of the receiver proxy, stubs and the proxy layer handle the kind. Pin test MaterialIconsRenderTest.iconsDefaultAddIsUnreachableBecauseTheWalkerBindsNoExtensionProperty must flip to a render test drawing Icon(Icons.Default.Add, contentDescription=None) from Python.

  2. added 2 commits that reference this issue on Oct 3, 2026
  3. b-re-w commented on Oct 3, 2026

    @b-re-w
    MemberAuthor

    Landed in develop via #65.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions