Skip to content

Target-typed switch expression doesn't handle typing well #81022

@DoctorKrolic

Description

@DoctorKrolic

Similar to #73894, #81021

Version Used:
Latest VS 2026 [11201.2]

Steps to Reproduce:

class C
{
    public DateTime M(int i)
    {
        return i switch
        {
            1 => new($$),
            _ => default,
        };
    }
}

Start typing ticks at $$

Expected Behavior:
I get ticks: completion since it is one of possible constructor parameters

Actual Behavior:
When completion is invoked in empty parens, ticks: is in the list. If you start typing, it is not there.

This is the same as #81021 in its core: when there is an error , compiler bails out without trying to recover, thus type information of each switch arm is lost so IDE cannot determine completion based on type of new()

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions