meetings/2017/LDM-2017-03-28.md
Design some remaining 7.1 features
Today x as T is allowed if
But for the is operator we don't have the second. That means that we can't always replace uses of as followed by null check with an is with a type pattern.
Also, the restrictions are supposed to rule out only obviously useless cases, whereas some of these are demonstrably useful.
Let's allow it, look again if there are unexpected problems.
Best common type should combine a value type with null literal to get a nullable value type.
b1 ? 1 : b2 ? null : b3 ? 2 : default; // default is 0
b1 ? 1 : b2 ? default : b3 ? 2 : null; // default is null
b1 ? 1 : (b2 ? null : (b3 ? 2 : default)); // default is 0
b1 ? 1 : (b2 ? default : (b3 ? 2 : null)); // default is null
This is weird, but fine:
M(1, default, null); // int?
Next step is trying to spec it. It's a bit complicated.
M(myShort, myNullableInt, null); Should continue to infer int? , not short?