Skip to content

Apply return annotations in the wrapper and keep Type arguments in inference - #26

Merged
lkdvos merged 2 commits into
mainfrom
annotation-inference
Nov 3, 2026
Merged

lkdvos merged 2 commits into
mainfrom
annotation-inference

Conversation

@lkdvos

@lkdvos lkdvos commented Nov 2, 2026

Copy link
Copy Markdown
Member

Closes #25.

  • Return annotations. The annotation of a @cached method is no longer copied onto MemoizationKit.implementation. It is evaluated in the wrapper and passed to call as the value type V, and _compute(...)::V converts the computed value. Conversion semantics are kept for cached calls (e.g. ::Float64 on a body returning an Int), and JET no longer reports the uncorrelated convert pairs in the body. As a consequence, uncached returns the value of the body without conversion; this is documented and tested.
  • Unannotated inference. The value type is inferred from Tuple{map(Core.Typeof, args)...}, computed in the wrapper and passed as InferValue{A}(), instead of typeof(args). Type{T} arguments (including varargs of types) now keep T, so such bodies infer without an annotation.

Tested with the reproducer from #25: JET is clean on both the wrapper and implementation, and the type-argument cases are @inferred, with allocation-free hits. TensorKit's JET analysis also passes with this branch without the ignores added for treebraider/treetransposer.

🤖 Generated with Claude Code

…ference

The return type annotation of a `@cached` method is no longer copied onto
`MemoizationKit.implementation`; `_compute` converts the computed value to it
instead. With the annotation in the body, JET union-split the annotated type and
the value independently and reported conversions that cannot happen.

Without an annotation, the value type is inferred from the argument types as seen
by dispatch (`Core.Typeof`), so `Type{T}` arguments no longer become `DataType`.

Closes #25.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Nov 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
ext/MemoizationKitSQLiteExt.jl 98.18% <100.00%> (ø)
src/call.jl 96.77% <100.00%> (+0.22%) ⬆️
src/disk.jl 92.30% <100.00%> (ø)
src/macro.jl 97.29% <100.00%> (+0.23%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@lkdvos
lkdvos merged commit bc1346f into main Nov 3, 2026
7 checks passed
@lkdvos
lkdvos deleted the annotation-inference branch November 3, 2026 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

@cached return annotation on the uncached body gives JET false positives, and the unannotated fallback loses Type arguments

1 participant