Repository navigation
Apply return annotations in the wrapper and keep Type arguments in inference - #26
Merged
Merged
Conversation
…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 Report✅ All modified and coverable lines are covered by tests.
🚀 New features to boost your workflow:
|
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #25.
@cachedmethod is no longer copied ontoMemoizationKit.implementation. It is evaluated in the wrapper and passed tocallas the value typeV, and_compute(...)::Vconverts the computed value. Conversion semantics are kept for cached calls (e.g.::Float64on a body returning anInt), and JET no longer reports the uncorrelatedconvertpairs in the body. As a consequence,uncachedreturns the value of the body without conversion; this is documented and tested.Tuple{map(Core.Typeof, args)...}, computed in the wrapper and passed asInferValue{A}(), instead oftypeof(args).Type{T}arguments (including varargs of types) now keepT, 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 fortreebraider/treetransposer.🤖 Generated with Claude Code