Skip to content

-mm=own: casts to any keep field families; interface slots are a method's callers - #721

Merged
ASDAlexander77 merged 1 commit into
mainfrom
own-open-families
Oct 28, 2026
Merged

ASDAlexander77 merged 1 commit into
mainfrom
own-open-families

Conversation

@ASDAlexander77

Copy link
Copy Markdown
Owner

Two callback families under -mm=own stayed open that need not (spec §59).

A class's callback field after a cast to any, a union, unknown or object. The only way back to the field is a cast to the class (an unbox, or a union narrowed by instanceof), and the family already sees that class's ts.PropertyRef in this module. Another module can cast back only to a class it can name, and the family is already open for such a class (callableFromOutside of its constructor). collectFieldFamilies no longer keeps the escaping set.

A callback parameter of a method an interface's vtable holds. When every interface slot holding the method is closed (interfaceFamilies, spec 31) and the method is not interfaceReached, its callers are every call through those slots (interfaceCallsOf). parameterOf now returns a set (FamilyTargets): a callback given on through an interface's slot reaches every class that fills it, and counts as given to a closed family only when all of their families are closed.

Tests:

  • own_callback_cast and own_callback_interface_slot run under own, rc, gc and none; own emits no counting for them.
  • Negative tests own_err_callback_cast_field_drops, own_err_callback_interface_slot_drops and own_err_callback_interface_slot_targets.

Validated on Windows: ctest 6148/6148, and the default library's release tests pass under gc, rc, none and own. Not run on Linux locally.

Not in this PR: arrow functions in object literals given to function-typed fields (f1({ w: x => x }, 0)). They compile as methods bound to a literal object that nothing owns. Fixing that means changing how MLIRGen builds object-literal arrows, not this pass.

🤖 Generated with Claude Code

…od's callers

Two callback families stayed open that need not (own spec 59):

- A class's callback field once an object of the class became `any`, a
  union, `unknown` or `object`. Every way back to the field is a cast to the
  class (an unbox, a union narrowed by instanceof), whose `ts.PropertyRef` the
  family sees here; another module can cast back only to a class it names, and
  a class it names is one it can build, which opens the family already.
  collectFieldFamilies drops the `escaping` set.
- A callback parameter of a method an interface's vtable holds. When every
  slot holding it is closed (interfaceFamilies, spec 31) and it is not
  interfaceReached, its callers are every call through those slots
  (interfaceCallsOf), whose arguments join its families with its direct
  calls'. parameterOf returns a set (FamilyTargets): a value given on through
  an interface's slot reaches each member, and passes to a closed family only
  when all of them are.

Tests: own_callback_cast and own_callback_interface_slot (own, rc, gc, none;
own emits no counting); negatives own_err_callback_cast_field_drops,
own_err_callback_interface_slot_drops, own_err_callback_interface_slot_targets.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ASDAlexander77
ASDAlexander77 merged commit 04df858 into main Oct 28, 2026
2 checks passed
@ASDAlexander77
ASDAlexander77 deleted the own-open-families branch October 28, 2026 21:12
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.

1 participant