Fix un-buildable main: ParameterInfo[]/Type[] mismatch in generator instance stubs (re-enables #723/#737/#738/#739)#794
Fix un-buildable main: ParameterInfo[]/Type[] mismatch in generator instance stubs (re-enables #723/#737/#738/#739)#794nickna wants to merge 1 commit into
Conversation
… instance-stub DC init EmitGeneratorFunctionDCInit takes `Type[]? paramTypes` (it boxes value-type params with these), but the generator and async-generator instance stub methods pass their `paramTypes` local, which #786 (#720) changed to `methodBuilder.GetParameters()` (a ParameterInfo[], the method's actual IL signature) while #769 (#724/#725) independently added the call passing a Type[]. Each PR compiled in isolation; merged together without a rebase, a ParameterInfo[] flows into a Type[]? parameter and main fails to compile (CS1503) at ILCompiler.Generators.cs:557 and ILCompiler.AsyncGenerators.cs:376. Convert at the two call sites with `.Select(p => p.ParameterType).ToArray()` — the dominant codebase idiom for GetParameters() -> Type[] — preserving #720's "box from the actual IL signature" behavior so private/all-object and #737-widened slots are not spuriously boxed (matching the field-seeding loop just above each call). Re-enables the compiled default/optional-parameter cluster from #787; the #723/#737/ #738/#739 repros are verified green (compiled == interpreted) and the full unit suite is 13352 passed / 0 failed. Filed #790 (different-arity override dispatch) and #792 (defaulted + captured generator parameter) as pre-existing gaps surfaced while verifying. Fixes #723, #737, #738, #739.
|
Closing as superseded — a concurrent session fixed the same build break first. This PR repaired an un-buildable CI here is red only because the PR is built merged with the now-fixed main, which produces the reverse mismatch ( Verification still stands and was re-run against current
|
What this fixes
origin/maincurrently does not compile:This is a semantic merge conflict between two independently-correct PRs that were merged without being rebased onto each other:
e64f3adb, compiled closures Compiled: arrow inside an INSTANCE generator method that writes a captured variable (function DC not wired) #724/Compiled: arrow inside an ASYNC generator body that writes a captured variable (full function-DC fix) #725) addedEmitGeneratorFunctionDCInit(…, Type[]? paramTypes)and called it from the generator / async-generator instance stub methods, passing theirparamTypeslocal (then aType[]).b95b6945, "Fix Compiled mode: async/generator private methods (async #m,*#m) emit invalid IL / unsupported #720: async/generator private methods emit invalid IL") changed that sameparamTypeslocal from the AST-resolvedType[]tomethodBuilder.GetParameters()(aParameterInfo[]) — deliberately, so boxing is decided from the method's actual IL signature (a private method's params are allobjectslots; boxing an AST-resolveddoubleinto anobjectslot is aStackUnexpected).Each compiled in isolation; together a
ParameterInfo[]flows into aType[]?parameter → CS1503. (Neither side is #787 — that is simply what surfaced this when I went to verify it.)The fix
Convert at the two call sites with
.Select(p => p.ParameterType).ToArray()— the dominant idiom in this codebase forGetParameters()→Type[](ILCompiler.Classes.Methods.cs:1250,Static.cs:438,Constructors.cs:363). This preserves #720's "box from the actual IL signature" intent: for a private/all-object or #737-widened-to-objectslot,ParameterTypeisobject, soIsValueTypeis false and nothing is spuriously boxed — exactly matching the field-seeding loop directly above each call.(I considered widening the helper to
ParameterInfo[]?instead, but it genuinely operates onType— it boxes with the element and checks.IsValueType— and two of its four callers passnull; the call-site conversion is the smaller, more idiomatic change.)Why this matters / relation to #723 #737 #738 #739
The compiled default/optional-parameter cluster (#705/#723/#737/#738/#739) was implemented and merged in #787, but the later merge above left
mainun-buildable, so those features could not actually run. With the build repaired I verified all four issues' repros, compiled output matching the interpreter:new C().m(5)→7,C.st(5)→7, string default→xz✓--compile --ref-asmvalue-call no longer shifts args (f(4)→7) ✓undefinedsentinel #739 omitted optional readsundefined(typeof→"undefined") ✓Existing coverage
Generator_InstanceMethodCallbackMutatesCapturedParameter— an instance generator method whose arrow mutates a captured value-type parameter, the exact path repaired here — exercises the boxing branch and passes. Full unit suite green (13352 passed, 0 failed, 1 skipped).Follow-ups filed (pre-existing gaps surfaced while verifying)
No new tests added: the break is compile-time (caught by any build) and its runtime path is already covered; the two follow-ups are failing cases tracked as issues.
Fixes #723, #737, #738, #739.