On 01/02/2014 22:05, Adam D. Ruppe wrote:
On Saturday, 1 February 2014 at 18:58:11 UTC, Andrei Alexandrescu wrote:
    Widget w = fetchWidget();
    if (w)
    {
        ... here w is automatically inferred as non-null ...
    }

A library solution to this exists already:

Widget wn = fetchWidget();
if(auto w = wn.checkNull) {
    // w implicitly converts to NotNull!Widget
}

I read your recent post about this, it was interesting. But I don't think you can disallow this:

    auto cn = checkNull(cast(C)null);
    NotNull!C nn = cn;

obj2 is then null, when it shouldn't be allowed.

Reply via email to