Skip to content

Keep declared methods of generic class instances after a computed-key write - #1215

Merged
ctate merged 6 commits into
mainfrom
ctate/keep-declared-methods-f5e06b
Oct 18, 2026
Merged

ctate merged 6 commits into
mainfrom
ctate/keep-declared-methods-f5e06b

Conversation

@ctate

@ctate ctate commented Oct 17, 2026

Copy link
Copy Markdown
Collaborator
  • Generic class instances, mixin classes and their subclasses keep their methods when a computed-key write marks the method names as replaceable.
  • Calls on these classes check for an own property and otherwise call the declared method; own-property replacements stay visible.

Fixes #963

… write

When a write with a computed string key can replace any method, calls of
every method name read the receiver's property bag without checking for
the key, and the bag falls back to the class's prototype data. Generic
class instantiations, mixin classes and their subclasses have no prototype
data, so their methods read as undefined and calls threw "x.status is not
a function". Reads on these classes now check for an own property and
otherwise use the declared method.

Fixes #963
Co-authored-by: Quim T. <[email protected]>
@vercel

vercel Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
scriptc Ready Ready Preview, v0 Oct 18, 2026 5:31am UTC

…write

observedPrototypeMethod skipped classPrototypeData for function-local
classes, which also marks such a class as needing prototype data, so its
instances got no prototype behind their property bag. A function-local
class value's prototype holds only methods the program replaced there, so
reads of a marked method name on its instances now check for the
property, own or inherited, and otherwise use the declared method, as for
generic class instances. The prototype data is built again, so a method
replaced on the class's prototype stays visible.
@ctate
ctate merged commit 54ab14d into main Oct 18, 2026
66 checks passed
@ctate
ctate deleted the ctate/keep-declared-methods-f5e06b branch October 18, 2026 06:00

This branch was successfully deployed

1 active deployment
Preview — 421e98f5 Deployed Oct 18, 2026 by vercel[bot]
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.

Methods of generic classes resolve to undefined once their name is demoted to prototypeMethodAccesses

1 participant