Add ObjectType-boxing infrastructure: getFields, spread, tuple cast#248
Merged
Conversation
… tuple cast Generalizes the generator-wrapper's BoxAsObject boxing (PR #245) toward supporting any object literal with methods: getFields now looks through ObjectType to its storage type, object spread ({...obj}) handles a boxed ObjectType source, and castTupleLikeVariants gained an ObjectType->tuple unboxing cast. No behavior change for existing code paths; verified via generator objects (the only literals boxed today) in new test 00object_boxed_infra.ts. Full suite: 352/352 JIT + 356/356 AOT. See docs/object-literal-boxing-design.md for the full staged plan (this is PR A of three). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2 tasks
ASDAlexander77
added a commit
that referenced
this pull request
Jul 18, 2026
…ype (#249) Generalizes the generator-wrapper's BoxAsObject boxing (PR #245, PR #248) to any object literal with a method or accessor: mlirGen(ObjectLiteralExpression) now boxes whenever oli.methodInfos/methodInfosWithCaptures is non-empty, not just synthetic wrappers carrying the flag. Every alias of such a literal (second binding, parameter, closure capture, array/object element) now shares mutable state, matching JS semantics; pure-data literals keep value (struct) semantics. The flip itself is two lines, but exercising ObjectType through every path that previously only saw tuples for method-bearing literals surfaced five more missing ObjectType cases, each fixed: - boxing seed value routed through mlirGenCreateTuple instead of the generic cast pipeline, avoiding a spurious "losing this reference" warning - TupleGetSetAccessor's get/set now handles a pointer (ObjectType/RefType) operand via PropertyRefOp+LoadOp, not just ExtractPropertyOp - castObjectToInterface gained the same field-type-coercion fallback castTupleToInterface already had (e.g. si32 vs number) - element access (obj[Symbol.x]) dispatches ObjectType like Class/Interface - generic intersection-type merge (D & M) and parameter inference look through ObjectType's storage type, same as MLIRTypeHelper::getFields New test 00object_ref_semantics.ts covers alias mutation through bindings, parameters, closures, array/object elements, accessors, globals, and conditional-expression merges. Full suite green: 353/353 JIT + 357/357 AOT. See docs/object-literal-boxing-design.md (PR B of three staged PRs). Co-authored-by: Claude Sonnet 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.
Summary
BoxAsObjectboxing (PR Box the generator wrapper as a heap-allocated ObjectType instead of a value tuple #245) so any object literal with methods can eventually be boxed asObjectType(design indocs/object-literal-boxing-design.md) — this PR is pure infrastructure, no behavior change.MLIRTypeHelper::getFieldsnow looks throughObjectTypeto its storage type.{...obj}) handles a boxedObjectTypesource (previously hitllvm_unreachable).castTupleLikeVariantsgained anObjectType→ tuple unboxing cast (needed for annotated declarations likeconst x: { m(): void } = someBoxedLiteral).Test plan
test/tester/tests/00object_boxed_infra.tsexercises all three gaps via generator objects (the only literals boxed asObjectTypetoday), registered as bothtest-compile-00-objects-boxed-infraandtest-jit-00-objects-boxed-infra.ctest --test-dir <builddir> -C Debug -R "^test-jit-"/"^test-compile-"-j8).🤖 Generated with Claude Code