Files
scriptc/tests/corpus/js-class-late-method-values.js
Chris Tate a07998f667 Expand static three.js workflows and host integration (#621)
* Expand static three.js workflows and host integration

* Preserve JavaScript class state in static three.js workflows

* Preserve inferred JavaScript behavior across static workflows

* Preserve inferred callables and native compatibility boundaries

* Retain annotated JavaScript factory exports and bootstrap-safe call spreads

* Preserve Buffer and child callback identities in static packages

* Clarify JavaScript symbol spread support
2026-10-02 19:56:34 -05:00

29 lines
972 B
JavaScript

class Base {
constructor(value) { this.value = value; }
read() { return this.value; }
}
class Child extends Base {
read() { return this.value + 10; }
}
function extract(value) { return value.read; }
const base = new Base(1);
const first = extract(base);
const child = new Child(2);
const second = extract(child);
console.log(first.call(child), second.call(base), second === child.read);
const dynamic = JSON.parse('{}');
dynamic.base = base;
dynamic.child = child;
const methodName = JSON.parse('"read"');
console.log(dynamic.base[methodName].call(child), dynamic.child[methodName].call(base));
class Holder {
constructor() { this.child = null; }
attach(value) { this.child = value; }
extract() { return this.child.read; }
}
const holder = new Holder();
holder.attach(child);
console.log(Boolean(holder.child && holder.child.read), holder.extract().call(base));
child.read = function () { return this.value + 100; };
console.log(holder.extract().call(child));