Skip to content

Fix un-buildable main: ParameterInfo[]/Type[] mismatch in generator instance stubs (re-enables #723/#737/#738/#739)#794

Closed
nickna wants to merge 1 commit into
mainfrom
wrk/naughty-gould-1bc43f
Closed

Fix un-buildable main: ParameterInfo[]/Type[] mismatch in generator instance stubs (re-enables #723/#737/#738/#739)#794
nickna wants to merge 1 commit into
mainfrom
wrk/naughty-gould-1bc43f

Conversation

@nickna

@nickna nickna commented Jun 16, 2026

Copy link
Copy Markdown
Owner

What this fixes

origin/main currently does not compile:

Compilation/ILCompiler.AsyncGenerators.cs(376,107): error CS1503: Argument 6: cannot convert from 'System.Reflection.ParameterInfo[]' to 'System.Type[]?'
Compilation/ILCompiler.Generators.cs(557,107): error CS1503: Argument 6: cannot convert from 'System.Reflection.ParameterInfo[]' to 'System.Type[]?'

This is a semantic merge conflict between two independently-correct PRs that were merged without being rebased onto each other:

Each compiled in isolation; together a ParameterInfo[] flows into a Type[]? 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 for GetParameters()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-object slot, ParameterType is object, so IsValueType is false and nothing is spuriously boxed — exactly matching the field-seeding loop directly above each call.

-            EmitGeneratorFunctionDCInit(il, smBuilder.FunctionDCField, method, funcDCKey, paramOffset: 1, paramTypes);
+            EmitGeneratorFunctionDCInit(il, smBuilder.FunctionDCField, method, funcDCKey, paramOffset: 1,
+                paramTypes.Select(p => p.ParameterType).ToArray());

(I considered widening the helper to ParameterInfo[]? instead, but it genuinely operates on Type — it boxes with the element and checks .IsValueType — and two of its four callers pass null; 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 main un-buildable, so those features could not actually run. With the build repaired I verified all four issues' repros, compiled output matching the interpreter:

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.

… 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.
@nickna

nickna commented Jun 16, 2026

Copy link
Copy Markdown
Owner Author

Closing as superseded — a concurrent session fixed the same build break first.

This PR repaired an un-buildable main (CS1503 ×2: ParameterInfo[]Type[]? in the generator/async-generator instance stubs, from the #769×#786 merge seam) by converting at the two call sites. While it was open, main advanced to e8f39905, where commit 35640416 ("Fix broken build: EmitGeneratorFunctionDCInit param type (ParameterInfo[])") already fixed the identical break via the equivalent opposite approach — widening the helper's parameter to ParameterInfo[]? so the stub's methodBuilder.GetParameters() flows in directly. Both are correct and box from the actual IL signature; theirs landed first.

CI here is red only because the PR is built merged with the now-fixed main, which produces the reverse mismatch (Type[]ParameterInfo[]?). There is no longer any code change to make.

Verification still stands and was re-run against current main (e8f39905):

@nickna nickna closed this Jun 16, 2026
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