title: When using class delegation, is there a way to override members used by methods of the delegate object?
body: <p>When using class delegation in Kotlin, you can override members. However, the <a href="https://kotlinlang.org/docs/reference/delegation.html" rel="noreferrer">reference page on delegation</a> says:</p>
  
  <blockquote>
    <p>Note, however, that members overridden in this way do not get called from the members of the delegate object, which can only access its own implementations of the interface members.</p>
  </blockquote>
  
  <p>I want to override a property that is used by methods of the delegate object so that the methods of the delegate object call this overridden property. As the documentation says, overriding the property with the <code>override</code> keyword doesn't accomplish this. Is there a way that I can achieve this behavior? If not, is it a sign that I should be using inheritance instead?</p>
  
  <p>Here is a code example:</p>
  
  <pre><code>interface Base {
      val message: String
      fun print()
  }
  
  class BaseImpl(val x: Int) : Base {
      override val message = "BaseImpl: x = $x"
      override fun print() { println(message) }
  }
  
  class Derived(b: Base) : Base by b {
      // This property is not accessed from b's implementation of `print`
      override val message = "Message of Derived"
  }
  
  fun main(args: Array&lt;String&gt;) {
      val b = BaseImpl(10)
      val derived = Derived(b)
      derived.print()
  }
  </code></pre>
  
  <p>This code prints "BaseImpl: x = 10", but I want it to print "Message of Derived".</p>