Compile time constants and reference types
<p>Ok, consider the following code:</p>

<pre><code>    const bool trueOrFalse = false;
    const object constObject = null;

    void Foo()
    {
        if (trueOrFalse)
        {
            int hash = constObject.GetHashCode();
        }

        if (constObject != null)
        {
            int hash = constObject.GetHashCode();
        }
    }
</code></pre>

<p><code>trueOrFalse</code> is a compile time constant and as such, the compiler warns correctly that <code>int hash = o.GetHashCode();</code> is not reachable.</p>

<p>Also, <code>constObject</code> is a compile time constant and as such the compiler warns again correctly that <code>int hash = o.GetHashCode();</code> is not reachable as <code>o != null</code> will never be <code>true</code>.</p>

<p>So why doesn't the compiler figure out that:</p>

<pre><code>    if (true)
    {
        int hash = constObject.GetHashCode();
    }
</code></pre>

<p>is 100% sure to be a runtime exception and thus issue out a compile time error? I know this is probably a stupid corner case, but the compiler seems pretty smart reasoning about compile time constant value types, and as such, I was expecting it could also figure out this small corner case with reference types.</p>
