Skip to content

Specify type inference for constructor calls - #10312

Draft
MadsTorgersen wants to merge 4 commits into
mainfrom
madstorgersen-constructor-inference-proposal
Draft

Specify type inference for constructor calls#10312
MadsTorgersen wants to merge 4 commits into
mainfrom
madstorgersen-constructor-inference-proposal

Conversation

@MadsTorgersen

@MadsTorgersen MadsTorgersen commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Summary

  • allow a generic type's type argument list to be omitted in an object creation expression and inferred from constructor arguments
  • consume type-group lookup and generalized generic type inference, linking the existing target-typed inference proposal for target-derived behavior
  • construct one candidate set from bound and inferred types across all arities, then apply overload resolution once
  • specify the resulting type, implicit struct default constructors, initializer staging, and the compile-time boundary for dynamic construction

Champion issue: #9627

Specification

The authoritative draft is MadsTorgersen/csharpstandard#3. It updates standard/expressions.md, primarily §12.6.3 type inference and §12.8.17.2 object creation expressions.

Compatibility and open design

Same-name types can add candidates or introduce lookup and overload-resolution ambiguities. Target-derived bounds can alter inference, and dynamic construction still requires a singleton bound type group. The proposal retains phased fallback as the principal alternative and leaves dynamic inference and initializer-derived bounds open.

Align constructor inference with shared type groups, generalized target-aware inference, and a combined overload candidate set across type arities.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
MadsTorgersen and others added 3 commits August 17, 2026 15:18
Point to the independent generalized-inference and type-group proposals, streamline the combined candidate-set rationale, and align standard links with alpha-v12.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Compress the proposal around its literal syntax delta, constructor candidate construction, combined overload set, and owned compatibility questions.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Compress the proposal around constructor-specific syntax, candidate construction, combined overload resolution, compatibility, and unresolved extensions.

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