Support typed WorkManager worker APIs in the Android compiler #8

Closed
opened 2026-09-20 14:07:13 -04:00 by ober · 0 comments
Owner

Context

The jerboa-mail Android migration needs periodic background inbox sync through AndroidX WorkManager. Android application code must stay in typed Jerboa; raw Kotlin string/file escapes are not an acceptable workaround.

Using the currently pinned Android generator/runtime revisions, compiling a typed worker declaration that passes Class<out ListenableWorker> to PeriodicWorkRequest.Builder fails with typed-module diagnostics:

unknown-type-constructor
argument-type-mismatch

A narrowly scoped compiler experiment in the Jerboa core showed the missing type capability: compound Class<T> typing and Kotlin lowering to java.lang.Class<T> (including out projections). Its focused checker/lowering tests pass, but that support is not available through the Android app's current pinned toolchain.

Required support

Please expose a supported typed Android path for implementing and scheduling a WorkManager worker without embedding Kotlin source strings. At minimum, the toolchain should support:

  • Class<T> and Class<out T> in typed declarations and extern signatures, including a safe class literal or typed class lookup mechanism.
  • Extending Worker with a typed doWork override returning ListenableWorker.Result.
  • Constructing a PeriodicWorkRequest with the worker class and interval, then scheduling/canceling unique work through WorkManager.
  • Using the worker-provided Context to load the encrypted account configuration and execute background sync.

Acceptance criteria

  • Add a compiler/generator fixture that emits Kotlin for a typed Worker subclass and unique periodic scheduling/cancellation.
  • Compile that generated source against the pinned AndroidX WorkManager dependency with no hand-written Kotlin source embedded in .ss files.
  • Add an Android smoke test proving the generated worker can be registered and invoked by WorkManager.
## Context The `jerboa-mail` Android migration needs periodic background inbox sync through AndroidX WorkManager. Android application code must stay in typed Jerboa; raw Kotlin string/file escapes are not an acceptable workaround. Using the currently pinned Android generator/runtime revisions, compiling a typed worker declaration that passes `Class<out ListenableWorker>` to `PeriodicWorkRequest.Builder` fails with typed-module diagnostics: ```text unknown-type-constructor argument-type-mismatch ``` A narrowly scoped compiler experiment in the Jerboa core showed the missing type capability: compound `Class<T>` typing and Kotlin lowering to `java.lang.Class<T>` (including `out` projections). Its focused checker/lowering tests pass, but that support is not available through the Android app's current pinned toolchain. ## Required support Please expose a supported typed Android path for implementing and scheduling a WorkManager worker without embedding Kotlin source strings. At minimum, the toolchain should support: - `Class<T>` and `Class<out T>` in typed declarations and extern signatures, including a safe class literal or typed class lookup mechanism. - Extending `Worker` with a typed `doWork` override returning `ListenableWorker.Result`. - Constructing a `PeriodicWorkRequest` with the worker class and interval, then scheduling/canceling unique work through `WorkManager`. - Using the worker-provided `Context` to load the encrypted account configuration and execute background sync. ## Acceptance criteria - Add a compiler/generator fixture that emits Kotlin for a typed `Worker` subclass and unique periodic scheduling/cancellation. - Compile that generated source against the pinned AndroidX WorkManager dependency with no hand-written Kotlin source embedded in `.ss` files. - Add an Android smoke test proving the generated worker can be registered and invoked by WorkManager.
ober closed this issue 2026-09-20 19:37:47 -04:00
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ober/jerboa-android#8
No description provided.