title: Why can't I use type-checked variable in first condition as type-casted variable in second condition?
body: <pre><code>class A
  {
      boolean foo() {
          return true;
      }
  }
  </code></pre>
  
  <p>Why is the following giving syntax error?<br>
  <em>method is undefined for type</em></p>
  
  <pre><code>if(a instanceOf A &amp;&amp; a.foo()) {
  .....
  }
  </code></pre>
  
  <p>This works fine-</p>
  
  <pre><code>if(a instanceOf A &amp;&amp; ((A)a).foo()) {
  .....
  }
  </code></pre>