-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Description
Discovered in #80907
Steps to Reproduce:
class C
{
public void M(bool b, int i)
{
C[] cs = [a, default];
C c1 = b ? a : default;
C c2 = i switch
{
1 => a,
_ => default,
};
(C, int) t = (a, default);
}
}Hover over default literal in each expression
Expected Behavior:
I get type information about the literal
Actual Behavior:
Nothing is shown
Breakdown:
The underlying issue lies in the compiler layer. Althouth in each case target type can be determined, expressions don't get converted to it due to one of nested elements/expressions being directly an error. If an error isn't directly in the element/branch, e.g. if I change collection expression to [new(a), default] even though the first element still contains an error, types start to flow through, so I get correct type information both on new and default. The same applies to other examples as well.
There is theoretical IDE impact, but I believe it is extreamly rare to see it in practical applications