The current LDM position is that we use the annotation context to compute the annotations (oblivious versus non-nullable). We don't currently do this.
For example, in the declaration of a local variable. If a local variable is declared
is it oblivious in a disabled state, but non-null in an enabled state? For locals, I believe oblivious acts the same as nullable (i.e. the state you get on reading is based on tracking, but you're allowed to assign null).
What if the local's type is inferred?
#nullable disable
var s = ""; // Is s oblivious?
Also, when doing type inference, would we infer oblivious in a context where the nullability annotations are disabled, but non-null where nullability annotations are enabled?
#nonnull enable
T Copy<T>(T t) => t;
T M<T>(T t)
{
// warning: possibly null dereference; the inferred type argument to Copy is unannotated
Copy(t).ToString();
#nonnull disable
// no warning; the inferred type argument to Copy is oblivious
Copy(t).ToString();
}
If t above were declared as a nullable reference type (possibly containing null), would we get an annotated inferred type in both contexts?
The current LDM position is that we use the annotation context to compute the annotations (oblivious versus non-nullable). We don't currently do this.
For example, in the declaration of a local variable. If a local variable is declared
is it oblivious in a disabled state, but non-null in an enabled state? For locals, I believe oblivious acts the same as nullable (i.e. the state you get on reading is based on tracking, but you're allowed to assign null).
What if the local's type is inferred?
Also, when doing type inference, would we infer oblivious in a context where the nullability annotations are disabled, but non-null where nullability annotations are enabled?
If
tabove were declared as a nullable reference type (possibly containing null), would we get an annotated inferred type in both contexts?