class C {
string Worst(object i) {
// uses a boolean flag for the result and a conditional jump
return i is 1 or C(2) ? "aaa" : "bbb";
}
string Switch(object i) {
// falls back to switch arms when possible; this info isn't available for `is` expressions
return i switch { 1 or C(2) => "aaa", _ => "bbb" };
}
string Best(object i) {
// ideally it should be lowered as `||` - still "linear" without using a flag
return i is 1 || i is C(2) ? "aaa" : "bbb";
}
void Deconstruct(out int i) => throw null;
}
Relates to #45679
(sharplab.io)
Relates to #45679
(sharplab.io)