title: Property getter typed on Supertype instead of Implementation in Kotlin
body: <p>Suppose I have two classes, a <code>Base</code>and a <code>Impl</code>which extends <code>Base</code>.</p>
  
  <pre><code>package mypackage
  
  open class Base
  class Impl : Base()
  </code></pre>
  
  <p>How would I create a <strong>private property for the concrete <code>Impl</code>-Type (for internal use)</strong>, with a <strong>public getter typed as the <code>Base</code>-Type</strong>, to achieve polymorphism? My initial approach was like this:</p>
  
  <pre><code>class Test {
      private val myType = Impl()
          get():Base
  }
  </code></pre>
  
  <p>However, the Kotlin compiler complains:</p>
  
  <p><em>Error:(30, 11) Kotlin: Getter return type must be equal to the type of the property, i.e. 'mypackage.Impl'</em></p>
  
  <p>Basically, this is what it would look like in plain Java:</p>
  
  <pre><code>public class Test {
      private Impl myImpl = new Impl();
  
      public Base getBase() {
          return myImpl;
      }
  }
  </code></pre>
  
  <p>How could one achieve this? Am I missing something?</p>
  
  <p>P.S. I am aware of Backing Fields and creating custom methods as a workaround for getter, I was just curious on how to approach this in an elegant, Kotlin style manner.</p>