Add typed Kotlin Java Class types and class literals #85

Merged
ober merged 3 commits from feat/kotlin-class-generic into master 2026-09-20 16:00:24 -04:00
Owner

Add typed Kotlin Java Class<T> types and class literals

Unblocks ober/jerboa-android#8 (typed WorkManager worker APIs).

What

  • (Class T) is now a one-argument compound type in the typed checker and
    lowers to java.lang.Class<T> in the Kotlin backend. It composes with the
    existing Out/In projections, so (Class (Out ListenableWorker)) lowers
    to java.lang.Class<out ListenableWorker> — the exact signature AndroidX
    WorkManager's PeriodicWorkRequest.Builder accepts.
  • New (kotlin-class ClassName) extern target: takes no arguments and lowers
    to the compile-checked Kotlin class literal ClassName::class.java. It is
    a safe alternative to string-based Class.forName lookups for passing
    typed worker class tokens to scheduling APIs.
  • The literal flows through a new structured kt-class-literal KAST node with
    matching fail-closed validator and printer cases — no raw-source escape.
  • Raw (Class) stays rejected (bad-type-arity), matching every other
    compound type.

Why

The jerboa-mail Android migration needs periodic background inbox sync through
AndroidX WorkManager with typed Jerboa only. The current toolchain fails such
declarations with unknown-type-constructor / argument-type-mismatch
because compound Class typing and class-literal lowering did not exist.

Verification

  • make build clean.
  • make test-typed-kotlin — 241 passed, 0 failed (4 new: class-literal
    printer units, full-pipeline Class projection, class-literal lowering).
  • make test-typed-checker — 252 passed, 0 failed (2 new: kotlin-class extern
    accepts typed use, rejects call arguments).
  • make test-typed-parser — 58 passed, 0 failed.
  • make test-typed-core — 47 passed, 0 failed.
  • make test-typed-rust — 99 passed, 0 failed.
  • make test-typed-wrappers — 30 passed, 0 failed.
  • make test-typed-kotlin-conformance — 5 passed (compile/run stage skipped:
    no kotlinc on dev host).
  • make check-docs — 1356 passed; make data-check — OK.

VERSION 0.12.14 -> 0.12.15.

# Add typed Kotlin Java `Class<T>` types and class literals Unblocks ober/jerboa-android#8 (typed WorkManager worker APIs). ## What - `(Class T)` is now a one-argument compound type in the typed checker and lowers to `java.lang.Class<T>` in the Kotlin backend. It composes with the existing `Out`/`In` projections, so `(Class (Out ListenableWorker))` lowers to `java.lang.Class<out ListenableWorker>` — the exact signature AndroidX WorkManager's `PeriodicWorkRequest.Builder` accepts. - New `(kotlin-class ClassName)` extern target: takes no arguments and lowers to the compile-checked Kotlin class literal `ClassName::class.java`. It is a safe alternative to string-based `Class.forName` lookups for passing typed worker class tokens to scheduling APIs. - The literal flows through a new structured `kt-class-literal` KAST node with matching fail-closed validator and printer cases — no raw-source escape. - Raw `(Class)` stays rejected (`bad-type-arity`), matching every other compound type. ## Why The jerboa-mail Android migration needs periodic background inbox sync through AndroidX WorkManager with typed Jerboa only. The current toolchain fails such declarations with `unknown-type-constructor` / `argument-type-mismatch` because compound `Class` typing and class-literal lowering did not exist. ## Verification - `make build` clean. - `make test-typed-kotlin` — 241 passed, 0 failed (4 new: class-literal printer units, full-pipeline Class<out> projection, class-literal lowering). - `make test-typed-checker` — 252 passed, 0 failed (2 new: kotlin-class extern accepts typed use, rejects call arguments). - `make test-typed-parser` — 58 passed, 0 failed. - `make test-typed-core` — 47 passed, 0 failed. - `make test-typed-rust` — 99 passed, 0 failed. - `make test-typed-wrappers` — 30 passed, 0 failed. - `make test-typed-kotlin-conformance` — 5 passed (compile/run stage skipped: no kotlinc on dev host). - `make check-docs` — 1356 passed; `make data-check` — OK. VERSION 0.12.14 -> 0.12.15.
Add typed Kotlin Java Class types and class literals
All checks were successful
required-ci / gerbil-compat (pull_request) Successful in 4m0s
version-policy / required (pull_request) Successful in 4m50s
freebsd-required / required (pull_request) Successful in 11m59s
dtrace / freebsd-usdt (pull_request) Successful in 13m28s
required-ci / required (pull_request) Successful in 14m22s
af59b6535b
Support compound (Class T) typing and its lowering to java.lang.Class<T>,
composable with existing Out/In projections for Class<out T> worker-token
signatures. Add a (kotlin-class Name) extern target that lowers to the
compile-checked Kotlin class literal Name::class.java through a new
fail-closed KAST node, validator case, and printer case.

Bump VERSION 0.12.14 -> 0.12.15.
Exported externs are visible to later same-package typed libraries
Some checks failed
required-ci / gerbil-compat (pull_request) Successful in 4m0s
version-policy / required (pull_request) Successful in 4m44s
freebsd-required / required (pull_request) Successful in 12m12s
required-ci / required (pull_request) Failing after 13m5s
dtrace / freebsd-usdt (pull_request) Successful in 13m49s
af3ed357a5
exported-declarations skipped typed-extern declarations, so an extern
listed in (export ...) never entered the same-module-context call
environment and later typed-library forms in the same Kotlin package
could not call it. Add the extern case (mirroring the existing dead
branch in module-export-context) plus a checker regression test.
Use unique temporary paths in the parallel-compilation test
All checks were successful
required-ci / gerbil-compat (pull_request) Successful in 4m0s
version-policy / required (pull_request) Successful in 4m48s
freebsd-required / required (pull_request) Successful in 11m55s
dtrace / freebsd-usdt (pull_request) Successful in 13m5s
required-ci / required (pull_request) Successful in 14m5s
3b5718063d
The parallel compile test wrote fixed /tmp/a.ss, /tmp/b.ss, and
/tmp/c.ss paths. Concurrent CI jobs on a shared FreeBSD runner jail
collide on those names and call-with-output-file fails with
"operation not permitted" under the sticky /tmp directory, turning
required-ci red for unrelated changes. Build the paths with
make-temporary-file-name like the neighboring build tests already
do.
ober merged commit fc37ff398a into master 2026-09-20 16:00:24 -04:00
ober referenced this pull request from a commit 2026-09-20 16:00:26 -04:00
Sign in to join this conversation.
No reviewers
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!85
No description provided.