Skip to content

Compiled: static async generators (#778), class-expression generators (#765), computed symbol-method binding & class-expr symbol methods (#755 s1/s2)#795

Merged
nickna merged 1 commit into
mainfrom
wrk/vigorous-shockley-ad7ed7
Jun 16, 2026
Merged

Compiled: static async generators (#778), class-expression generators (#765), computed symbol-method binding & class-expr symbol methods (#755 s1/s2)#795
nickna merged 1 commit into
mainfrom
wrk/vigorous-shockley-ad7ed7

Conversation

@nickna

@nickna nickna commented Jun 16, 2026

Copy link
Copy Markdown
Owner

Completes three compiled-mode generator/symbol-method gaps. All four fixes route through the existing state-machine / symbol-registry infrastructure (no new machinery), are IL-verified, and run identically in both back ends.

Fixes #778 — compiled static async *m()

EmitStaticMethodBody routed a static async *m() into the plain-async branch, so its yield hit "Yield not supported in this context". (The sync static *m() was already handled by #692.) EmitAsyncGeneratorMethodBody is generalized with an isInstanceMethod flag plus a new static stub (EmitAsyncGeneratorStaticStubMethod, no this, params from arg 0, value-types boxed) — mirroring the sync static generator. EmitStaticMethodBody now dispatches static async *m() there first (it has both flags). The generator default-parameter prologue from #737 applies for free.

Fixes #765 — compiled generator methods in a class expression

const C = class { *gen() { yield … } } was emitted on the linear path (→ "Yield not supported"). The class-expression emitters now (a) give generator/async-generator methods the right return type (IEnumerable<object> / IAsyncEnumerable<object>) and (b) dispatch IsGenerator / IsAsync && IsGenerator to the same state-machine emitters as class declarations, for both instance and static forms. Covers this/field access, yield*, and the async/static variants. Arrow write-capture of a generator local still fail-fasts cleanly (the #674 guard) — its function-DC wiring is tracked as a follow-up (#789).

Fixes #755 (sub-cases 1 & 2) — computed symbol-keyed method follow-ups

  • Sub-case 1 — reading a symbol method as a value (obj[Symbol.iterator]) returned a raw MethodInfo, so a standalone obj[Symbol.iterator]() lost this (TargetException: Non-static method requires a target). The bracket-get now wraps it in new $TSFunction(obj, method), exactly like the string-key method path; InvokeWithThis uses the bound _target for an instance method (null for a static). $TSFunction is emitted into the output DLL, so this stays standalone-safe.
  • Sub-case 2 — class expressions now wire computed symbol-keyed methods through the same synthetic-method + _classes.SymbolMethods registry + .cctor registration as class declarations (building on the Compiled: generator methods in a class EXPRESSION are unsupported ("Yield not supported in this context") #765 generator routing). for…of / spread / for await / direct access all work, including the async-generator form and this-capture.

Sub-case 3 (non-symbol string/number computed keys) needs a runtime string-keyed method registry with a fallback in the hot named-property path — a distinct architectural change tracked in #791; its test stays interpreter-only.

Tests

The full SharpTS.Tests suite passes (13386 passed, 0 failed).

Notes

…#765), symbol-method binding + class-expr symbol methods (#755 s1/s2)

Route the remaining compiled-mode generator/symbol-method cases through the
existing state-machine and symbol-registry infrastructure (no new machinery);
all IL-verified and identical across both back ends.

#778: generalize EmitAsyncGeneratorMethodBody with an isInstanceMethod flag +
a static stub (no `this`); EmitStaticMethodBody dispatches `static async *m()`
there first. (Sync `static *m()` was already #692.)

#765: class-expression instance/static method emitters give generator /
async-generator methods the right return type and dispatch them to the same
state-machine emitters as class declarations.

#755 s1: the symbol-method bracket-get returns `new $TSFunction(obj, method)`
(receiver-bound) instead of a raw MethodInfo, so `obj[Symbol.iterator]()` keeps
`this`, mirroring the string-key path.

#755 s2: class expressions wire computed symbol-keyed methods through the same
synthetic-method + SymbolMethods registry + .cctor registration as declarations.

Follow-ups filed: #789 (class-expr generator arrow write-capture DC), #791
(#755 s3 non-symbol keys), #793 (class-expr inferred method return inference).

Full SharpTS.Tests suite green.
@nickna nickna force-pushed the wrk/vigorous-shockley-ad7ed7 branch from bb7ec2c to af892ad Compare June 16, 2026 19:15
@nickna nickna merged commit b5521e7 into main Jun 16, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant