Skip to content

Update type parameter inference from constraints specification - #10307

Open
agocke wants to merge 1 commit into
dotnet:mainfrom
agocke:update-constraint-inference-spec
Open

Update type parameter inference from constraints specification#10307
agocke wants to merge 1 commit into
dotnet:mainfrom
agocke:update-constraint-inference-spec

Conversation

@agocke

@agocke agocke commented Aug 14, 2026

Copy link
Copy Markdown
Member

Align the type parameter inference from constraints proposal with the prototype implementation in dotnet/roslyn#84655.

The updated specification:

  • distinguishes ordinary bounds from constraint bounds and gives ordinary bounds precedence;
  • excludes reflexive dependencies introduced solely by a self-referential constraint;
  • specifies that all type variables selected by the same fixing step are determined from the same inference state before constraint inference occurs;
  • defines constraint inference and its recursive bound classification;
  • adds examples for ordinary-bound precedence, cyclic dependencies, order independence, and termination; and
  • narrows the discussion of potential breaking changes to the behavior the prototype actually introduces.

Champion issue: #9453
Implementation: dotnet/roslyn#84655

Align the proposal with ordinary-bound precedence and order-independent fixing in the prototype implementation.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 1fcf8092-6a5f-485e-891d-26fe95919661
> When §12.6.3.3 determines whether `Xᵢ` has a non-empty set of bounds, and when §12.6.3.13 fixes `Xᵢ`, the bounds of `Xᵢ` are its effective bounds. The operations in §12.6.3.10
> through §12.6.3.12 that add bounds add ordinary bounds, except when those operations are performed as part of a constraint inference.

> *Note*: Constraint bounds are not combined with ordinary bounds. Constraint inference can therefore supply a type argument that ordinary inference could not determine, but does

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this split is done for backwards compatibility. Consider noting that somewhere so the intent is clear.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it's somewhat mentioned in the Drawbacks section.

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.

3 participants