Skip to content

javascript: new this.constructor() builds the receiver's class at each site - #1733

Merged
swapnilpaliwal-sd merged 1 commit into
0.1.7from
loop/ja-is465
Sep 29, 2026
Merged

swapnilpaliwal-sd merged 1 commit into
0.1.7from
loop/ja-is465

Conversation

@swapnilpaliwal-sd

Copy link
Copy Markdown
Contributor

new this.constructor() in a method returned every instantiated subclass of the declaring class, so each call on a clone fanned to all their overrides. It is now substituted per site from the call's receiver, like a this-return (#464). This covers a direct return and a const local that is filled in and then returned (the usual clone).

  • Controls, unchanged: a fixed new Base(), a let local, and new this() in a static (the compiler types that one as the declaring class).
  • New case 69; goldens 07 and 37 narrow to the receiver's override.
  • Checked: JS suite 78/78 with oracle, 0 defects on 69, real-app runtime recall 0.990, arity ok. Fixture: 16 → 7 edges on the 7 clone sites. A real query-builder app: 0 edges lost or gained, index 244 s → 255 s.

Part of #465 (the new this.constructor() item; #675 had reached a sound superset, this makes it exact).

…h site

A method returning `new this.constructor(...)`, directly or through a const it
initialises, was read as one merged value: every instantiated subclass of the
declaring class, so each call on a clone fanned to all their overrides. Like a
`this`-return, it is now substituted per site from the call's receiver. A `let`
local and `new this()` in a static keep their merged value.

Co-authored-by: axiomcode-bot[bot] <334110751+axiomcode-bot[bot]@users.noreply.github.com>
Co-Authored-By: Claude <noreply@anthropic.com>
@swapnilpaliwal-sd
swapnilpaliwal-sd merged commit 49702cd into 0.1.7 Sep 29, 2026
12 checks passed
@swapnilpaliwal-sd
swapnilpaliwal-sd deleted the loop/ja-is465 branch September 29, 2026 01:19
@swapnilpaliwal-sd swapnilpaliwal-sd mentioned this pull request Sep 29, 2026
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