-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Labels
Description
Target-typed inference for type patterns
- Specification: https://github.com/dotnet/csharplang/blob/main/proposals/inference-for-type-patterns.md
- Discussion: [Discussion]: Target-typed inference for type patterns #9631
Summary
Generic type inference is extended to type patterns, which may omit a type argument list when it can be inferred from the pattern input value. For instance, given a declaration Option<int> intOption, instead of:
if (intOption is Some<int> some) ...You can simply write:
if (intOption is Some some) ... // 'Some<int>' inferred from the type of 'intOption'