title: Smart cast to 'Boolean' is impossible after value affectation
body: <p>Error on the second println : </p>
  
  <blockquote>
    <p>Smart cast to 'Boolean' is impossible, because 'r.isSquare' is a
    mutable property that could have been changed by this time</p>
  </blockquote>
  
  <pre><code>fun main(args: Array&lt;String&gt;) {
      val r: Rectangle = Rectangle(5,5)
      println(r.isSquare)
      r.isSquare = true
      println(r.isSquare) // error but works with println(r.isSquare?:false)
  
  }
  
  data class Rectangle(var height: Int, var width: Int){
      var isSquare: Boolean? = null
  }
  </code></pre>
  
  <p><strong>If it was null, it would print null like the first println, why do i have to do this ?</strong> </p>
  
  <p><strong>Edit 2</strong></p>
  
  <p>Thanks for all your answers, what i understand now :
  First println is </p>
  
  <pre><code>println(message: Any?)
  </code></pre>
  
  <p>Second println is </p>
  
  <pre><code>println(message: Boolean)
  </code></pre>
  
  <p>Because r.isSquare = true make compiler trust that isSquare is Boolean and not anymore Boolean? </p>
  
  <p><strong>Edit2</strong></p>
  
  <p>Here is how i handle the compiler to keep trusting isSquare is Boolean?</p>
  
  <pre><code>fun main(args: Array&lt;String&gt;) {
      val r: Rectangle = Rectangle(5, 5)
      println(r.isSquare)
      r.isSquare = true as Boolean? // if no cast, he will try wrong println signature
      println(r.isSquare)
  }
  
  data class Rectangle(var height: Int, var width: Int){
      var isSquare: Boolean? = null
  }
  </code></pre>