Files
scriptc/tests/corpus/local-class-specialization.js
Chris Tate 31332427b6 Compile local class factories and spread calls natively
- Preserve fresh constructor identity and shared captures across local class instances.
- Carry constructors through unknown values without a JavaScript engine.
- Support runtime-length spreads into fixed and rest parameters.
2026-09-28 20:11:25 -05:00

17 lines
541 B
JavaScript

function make(value) {
return class Stored {
read() { return value; }
matches(other) { return other === value; }
};
}
const Numbers = make(12);
const OtherNumbers = make(25);
const Strings = make("hello");
const a = new Numbers();
const b = new OtherNumbers();
const c = new Strings();
console.log(Numbers.name, Numbers === OtherNumbers);
console.log(a.read(), b.read(), c.read());
console.log(a.matches(12), b.matches(12), c.matches("hello"));
console.log(a instanceof Numbers, a instanceof OtherNumbers, c instanceof Strings);