Skip to content

Generalize type inference and add target-derived bounds - #1

Draft
MadsTorgersen wants to merge 2 commits into
alpha-v12from
madstorgersen-generalized-type-inference
Draft

Generalize type inference and add target-derived bounds#1
MadsTorgersen wants to merge 2 commits into
alpha-v12from
madstorgersen-generalized-type-inference

Conversation

@MadsTorgersen

@MadsTorgersen MadsTorgersen commented Aug 13, 2026

Copy link
Copy Markdown
Owner

Summary

  • remodel §12.6.3 around construct-neutral declaration and context inputs
  • move method-invocation-specific setup into its own subsection
  • infer generic type arguments from an optional target type using upper-bound inference for by-value results and exact inference for by-ref results
  • use delegate return types when inferring generic methods in method-group conversions
  • leave the precise source of a method invocation's target type and ref kind as an explicit TBD pending the target-typing model

This is the bottom layer of the confirmed type-inference stack. It intentionally excludes constructor inference, type-group lookup, and higher-layer changes.

Commit structure

  1. Generalize the type inference algorithm preserves existing behavior while remodeling the specification.
  2. Infer generic types from target types contains the intentional semantic changes and provisional method-invocation hook.

Breaking changes

Target-derived inference can make previously failing candidates succeed, change inferred type arguments for candidates that already succeeded, introduce or remove ambiguities, change overload selection, or cause inference to fail where it previously succeeded. By-ref result and target types now contribute exact bounds; compatibility of their ref kinds remains the responsibility of the consuming target context.

Method-group conversions now use the delegate return type for inference. This makes previously failing conversions such as assigning G<T>() to a return-compatible delegate succeed, and can likewise change candidate sets, ambiguity, or selection.

These effects must be investigated and documented in the corresponding csharplang proposals.

Validation

  • temporary clause anchors and cross-links validated with StandardAnchorTags --dryrun
  • scoped cross-spec semantic-impact audit completed, including ref-local initialization, ref assignment, and invocation-result classification
  • final diff checked against pinned baseline a827d023182ffe63a393b57f740fae3e1ad5a206
  • scope and commit separation verified

@MadsTorgersen
MadsTorgersen force-pushed the madstorgersen-generalized-type-inference branch 2 times, most recently from d16e303 to 8e061f0 Compare August 13, 2026 22:51
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@MadsTorgersen
MadsTorgersen force-pushed the madstorgersen-generalized-type-inference branch 3 times, most recently from c42ec95 to 69f95a2 Compare August 13, 2026 23:55
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant