Compiled: static async generators (#778), class-expression generators (#765), computed symbol-method binding & class-expr symbol methods (#755 s1/s2)#795
Merged
Conversation
e1fff58 to
bb7ec2c
Compare
…#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.
bb7ec2c to
af892ad
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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()EmitStaticMethodBodyrouted astatic async *m()into the plain-async branch, so itsyieldhit "Yield not supported in this context". (The syncstatic *m()was already handled by #692.)EmitAsyncGeneratorMethodBodyis generalized with anisInstanceMethodflag plus a new static stub (EmitAsyncGeneratorStaticStubMethod, nothis, params from arg 0, value-types boxed) — mirroring the sync static generator.EmitStaticMethodBodynow dispatchesstatic 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) dispatchIsGenerator/IsAsync && IsGeneratorto the same state-machine emitters as class declarations, for both instance and static forms. Coversthis/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
obj[Symbol.iterator]) returned a rawMethodInfo, so a standaloneobj[Symbol.iterator]()lostthis(TargetException: Non-static method requires a target). The bracket-get now wraps it innew $TSFunction(obj, method), exactly like the string-key method path;InvokeWithThisuses the bound_targetfor an instance method (null for a static).$TSFunctionis emitted into the output DLL, so this stays standalone-safe._classes.SymbolMethodsregistry +.cctorregistration 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 andthis-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
StaticGeneratorMethodTests— +3 static async generator tests (bare-yield + for-await; param + real await; default-param + for-loop + await inside, the full Compiled: static generator methods (static *m()) fail with "Yield not supported in this context" #778 shape — all in both back ends).ClassExpressionTests— +6 (class-expression generator: basic, this/ctor-param capture,yield*, static, async, static-async).ComputedSymbolMethodTests— flippedDirectSymbolMethodAccess_ReturnsCallable(s1) andClassExpression_ComputedSymbolMethod_Works(s2) to both back ends, added an async class-expression symbol-method test.NonSymbolComputedMethodKey_FoldsToNamedMethod(s3) stays interpreter-only (Compiled: non-symbol (string/number) computed class method keys are unsupported #791).The full
SharpTS.Testssuite passes (13386 passed, 0 failed).Notes
mainafter a concurrent fix landed; the redundant build-fix hunk it briefly carried was dropped.forloop whose condition reads a parameter yields nothing #788, an interpreter async-generator for-loop bug found mid-work, was independently fixed by the async-generator rewrite already on main and is closed.)