title: Kotlin's logical 'and' doesn't short-circuit?
body: <p>I was following along Kotlin's documentation at <a href="http://kotlinlang.org/docs/reference/null-safety.html#checking-for-null-in-conditions" rel="noreferrer">http://kotlinlang.org/docs/reference/null-safety.html#checking-for-null-in-conditions</a> and tried adapting this example,</p>
  
  <pre><code>val b = "Kotlin"
  if (b != null &amp;&amp; b.length &gt; 0) {
      print("String of length ${b.length}")
  } else {
      print("Empty string")
  }
  </code></pre>
  
  <p>to the case where <code>b = null</code>. In an IntelliJ Idea Kotlin project I have an <code>app.kt</code> with a <code>main()</code> function defined as:</p>
  
  <pre><code>fun main() {
      val b = null
      if (b != null &amp;&amp; b.length &gt; 0) {
          print("String of length ${b.length}")
      } else {
          print("Empty string")
      }
  }
  </code></pre>
  
  <p>However, when I run this, I get two compilation errors:</p>
  
  <pre><code>Information:Kotlin: kotlinc-jvm 1.3.20 (JRE 11+28)
  Information:2019-02-02 15:07 - Compilation completed with 2 errors and 0 warnings in 1 s 921 ms
  /Users/kurtpeek/IdeaProjects/HelloWorld/src/app.kt
  Error:(3, 24) Kotlin: Unresolved reference: length
  Error:(4, 37) Kotlin: Unresolved reference: length
  </code></pre>
  
  <p>I understand that the compiler is evaluating <code>b.length</code> even though the first condition, <code>b != null</code>, is <code>false</code>. This surprises me because I thought that the first check was to 'short-circuit' the Boolean expression if needed and make the call to <code>b.length</code> 'safe'.</p>
  
  <p>For example, in Python, you can do this:</p>
  
  <pre><code>In [1]: "foo" == "bar" and what.the.heck
  Out[1]: False
  </code></pre>
  
  <p>which works even though <code>what</code> is not defined, because the <code>and</code> 'stops' since <code>"foo"</code> is not equal to <code>"bar"</code>.</p>
  
  <p>Is this indeed how Kotlin works? It seems like missing Python's 'short-circuiting' feature would be a limitation.</p>