Skip to content

[Proposal]: Partial Type Inference #8968

Open
@RikkiGibson

Description

@RikkiGibson

Discussion: #8967

See #1348
See also #7582

Currently, in an invocation of a generic method, you either have to specify all of the type arguments or none of them, in the latter case depending on the compiler to infer them for you. The proposal is to permit the programmer to provide some of the type arguments, and have the compiler infer only those that were not provided.

There are (at least) three possible forms this could take:

  1. Named type arguments (Discussion: Named type arguments #280, Proposal: Allow partial generic specification #1348), e.g. M<TElement: int>(args)
  2. Omitted type arguments separated by commas, e.g. M<int, >(args)
  3. Types to be inferred specified by var (Proposal: Allow partial generic specification #1348), e.g. M<int, var>(args)

Design Meetings

https://github.com/dotnet/csharplang/blob/main/meetings/2024/LDM-2024-02-07.md#partial-type-inference

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions