Specify constructor type inference - #3
Draft
MadsTorgersen wants to merge 9 commits into
Draft
Conversation
MadsTorgersen
changed the base branch from
madstorgersen-generalized-type-inference
to
madstorgersen-type-groups
August 14, 2026 17:34
Consume type groups during object creation, infer generic containing type arguments from constructor arguments and target types, and resolve all arities in one overload set. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Use direct type and type-group-name object creation alternatives, then consume the resolved type group during constructor binding. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
MadsTorgersen
force-pushed
the
madstorgersen-constructor-inference
branch
from
August 14, 2026 19:25
933c73f to
18792e9
Compare
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: b9ac6346-e36b-4201-96bf-2688ecedd2bf
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: b9ac6346-e36b-4201-96bf-2688ecedd2bf
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: b9ac6346-e36b-4201-96bf-2688ecedd2bf
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: b9ac6346-e36b-4201-96bf-2688ecedd2bf
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: b9ac6346-e36b-4201-96bf-2688ecedd2bf
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: b9ac6346-e36b-4201-96bf-2688ecedd2bf
This was referenced Aug 17, 2026
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.
Summary
type_groupproduction directly in object creationDepends on #2. This PR is stacked on
madstorgersen-type-groupsat85b5a7d32e8faf3f0b13bf915620609948030cf5.Type-group consumption
Object creation now accepts the
type_groupproduction defined by the intervening layer. Constructor binding consumes the set to which that production resolves; it does not duplicatetype/type_group_namerecognition or lookup and does not use the removedtype_designatorabstraction.Explicit bound types resolve to singleton groups. A type-group name can contribute same-name unbound types of multiple arities. Target-typed
newsupplies an implied type, modeled as a singleton set during constructor binding.Design choice: one candidate set
The earlier drafts contain both phased-fallback and combined-candidate approaches. This layer uses one combined candidate set because the type-group layer defines a single lookup result containing same-name types of every arity, analogous to a method group whose later binding operation selects among all candidates. A non-generic type is therefore not tried in a separate first phase.
For the shared better-function-member rules, a constructor of a generic type is treated as the generic counterpart of a constructor of a non-generic type, with the containing type's parameters and inferred arguments. This lets existing generic/non-generic and specificity tie-breakers apply without changing the generalized inference algorithm.
Scope
This layer changes only constructor/object-creation inference. It does not modify type-group lookup, the generalized inference phases, method inference, type patterns, or any other proposed type-group consumer.
Semantic impact audit
Required in this layer
type_groupHigher-layer / TBD
Unaffected specialized behavior
newcontinues to provide an implied bound typeBreaking-change consequences
Open questions
Validation
git diff --checkdotnet run --no-launch-profile --project StandardAnchorTags\StandardAnchorTags.csproj -- --owner dotnet --repo csharpstandard --dryrunfromtools\The anchor dry run passes with only the repository's existing
NU1510warning forSystem.Text.Json.