classes-2-extends-mixin-call.ts 765 B

1234567891011121314151617181920
  1. // A class extending a mixin CALL (`class D extends mix(Base) {}`). D itself resolves,
  2. // but its heritage expression is a call, so the base class (and the inherited ctor)
  3. // cannot be found. Runtime: new D(<ask result>) forwards through the implicit ctor
  4. // chain to Base's ctor, which stores the artifact in this.v; d.v then feeds ask#2.
  5. // Expected: source -> ask#1, ask#1 -> ask#2 (base ctor -> this.v -> d.v), ask#2 -> sink;
  6. // ask#1 carries actors=actor#1.
  7. const seed = agent("w").ask<string>("s");
  8. class Base {
  9. v = "";
  10. constructor(x: string) {
  11. this.v = x;
  12. }
  13. }
  14. function mix(B: typeof Base) {
  15. return class extends B {};
  16. }
  17. class D extends mix(Base) {}
  18. const d = new D(await seed);
  19. const out = await agent("r").ask<string>(`use ${d.v}`);
  20. return out;