// Create an expr for exprSrc.Value where exprSrc.type is a NullableType.
private static Expr BindNubValue(Expr exprSrc)
{
Debug.Assert(exprSrc != null && exprSrc.Type is NullableType);
// For new T?(x), the answer is x.
if (IsNullableConstructor(exprSrc, out ExprCall call))
{
Expr args = call.OptionalArguments;
Debug.Assert(args != null && !(args is ExprList));
return(args);
}
NullableType nubSrc = (NullableType)exprSrc.Type;
CType typeBase = nubSrc.UnderlyingType;
AggregateType ats = nubSrc.GetAts();
PropertySymbol prop = PredefinedMembers.GetProperty(PREDEFPROP.PP_G_OPTIONAL_VALUE);
PropWithType pwt = new PropWithType(prop, ats);
MethPropWithInst mpwi = new MethPropWithInst(prop, ats);
ExprMemberGroup pMemGroup = ExprFactory.CreateMemGroup(exprSrc, mpwi);
return(ExprFactory.CreateProperty(typeBase, null, null, pMemGroup, pwt, null));
}