Repository navigation
-mm=own: a method call on another module's @final class keeps its borrows - #681
Merged
Merged
Conversation
…rows A call on an object of a @Final class another module defines still goes through the vtable, so the signature pass resolved it to the method's family, whose imported members it cannot see, and the call might drop anything: a borrowing record could not be read across it, though the library lists the method in __own_no_drops. No class can extend a @Final one, so the slot holds the method the call names. MLIRGen now marks such a ts.ThisVirtualSymbolRef __final_receiver, and resolveValue resolves it as a call to that function, so addImported applies. A method of a class that is not @Final may be overridden where the importer cannot see, so a call of one still ends the record's borrows (import_own_record_open_method.ts). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ASDAlexander77
added a commit
that referenced
this pull request
Oct 24, 2026
…ws too (#682) #681 resolved a method call on an object of another module's @Final class as a call to the method it names, so the library's __own_no_drops applied. An accessor goes through the vtable by a ts.VirtualSymbolRef instead, which still resolved to its family, so reading a getter or assigning a setter ended every borrow it could reach: a record could not be read across `m.weight`. MLIRGen now marks an accessor's ts.VirtualSymbolRef __final_receiver as it marks a method's ts.ThisVirtualSymbolRef, and resolveValue reads it the same way. An accessor the library does not list still drops (import_own_record_final_drops.ts: a setter that replaces the borrowed node). 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.
Problem
Under
-mm=own, a borrowing record (§32) could not be read after a method call on an object of another module's class, even when the library lists that method among its__own_no_drops. The call goes through the vtable, soresolveValueresolved it to the method's family. The importer cannot see the imported members of that family, so the call was unknown and might drop anything.Fix
A
@finalclass has no subclass, so its vtable slot holds the method the call names.ts.ThisVirtualSymbolRefof a@finalreceiver that is not called directly (the class is defined in another module) with__final_receiver(FINAL_RECEIVER_ATTR_NAME).resolveValueresolves such a reference as a call to the function it names, not to its family, soaddImported, and with it the library's__own_no_drops, applies.A method of a class that is not
@finalmay be overridden where the importer cannot see the override, so a call of one still ends the record's borrows.Not covered: accessors on an imported
@finalclass (ThisIndirectAccessorOp).Tests
export_own_record.ts:Maker.weigh(on the@finalclassMaker) and a non-finalOpen.look. Both destroy nothing.import_own_record.ts: both records are read acrossm.weigh(...). It runs under gc, rc and own, AOT and JIT, andown-shared-record.cmakestill counts two box releases.import_own_record_open_method.ts(new negative): a read aftero.look(a)is still refused.Spec notes: own memory model §15.7, final classes ("Amended 2026-10-24").
🤖 Generated with Claude Code