#9453·csharplang

[Proposal]: Type Parameter Inference from Constraints

Author: 333fredCreated Jun 17, 2025Updated Aug 13, 2026
LabelsProposal champion

Type Parameter Inference from Constraints

Summary

Allow type inference to succeed in overload resolution scenarios by promoting generic constraints of inferred type parameters to "fake arguments" during type inference, enabling the bounds of type variables to participate in the inference process. An example is:

cs
List<int> l = [1, 2, 3];
M(l); // Today: TElement cannot be inferred. With this proposal, successful call.

void M<TEnumerable, TElement>(TEnumerable t) where TEnumerable : IEnumerable<TElement>
{
    Console.WriteLine(string.Join(",", t));
}

Design meetings