title: "Leaking 'this' in constructor" warning should apply to final classes as well as open ones?
body: <p>In Kotlin if you have an <code>open</code> class which refers to <code>this</code> in its constructor or <code>init</code> block, you (quite rightly) get a compiler warning:</p>
  
  <blockquote>
    <p>Leaking 'this' in constructor of non-final class</p>
  </blockquote>
  
  <p>The reason for this is explained <a href="https://stackoverflow.com/a/9851843/10326373">here</a>.</p>
  
  <p>My question is: why is this <strong>not</strong> reported when the class is final?  If <code>this</code> is used in the <code>init</code> block before that block has completed, the object is still not in a fully constructed state, so shouldn't the warning apply there too?</p>
  
  <p>This can even lead to a situation where a <code>val</code> property seems to change at runtime.  Take this code as an example:</p>
  
  <pre><code>class Listener {
      fun onCreated(leaker: Leaker) = println("Listener hears that leaker created with a value of ${leaker.myVal}")
  }
  
  class Leaker(listener: Listener) {
      val myVal: Int
  
      init {
          listener.onCreated(this)
          myVal = 1
          println("Leaker knows that it's been created with a value of $myVal")
      }
  }
  </code></pre>
  
  <p>Using these objects as follows: </p>
  
  <pre><code>Leaker(Listener())
  </code></pre>
  
  <p>will result in the following output:</p>
  
  <pre><code>Listener hears that leaker created with a value of 0
  Leaker knows that it's been created with a value of 1
  </code></pre>
  
  <p>Notice that <code>myVal</code> is initially reported as being 0, then as being 1.</p>
  
  <p>As can be seen, <code>Leaker</code> passes an instance of itself to <code>Listener</code> before <code>Leaker</code> has been fully constructed. <code>Listener</code> can then access the <code>myVal</code> property before it's been initialized, so it'll have the default value (0 in this case as it's an integer). Later on <code>Listener</code> then changes the value of this property (to 1 in this example). This means that the program behaves as if a <code>val</code> has changed.</p>
  
  <p>Should the compiler warn you about this?</p>