title: Kotlin: When extension function hides the class default implementation?
body: <p>I'm trying to figure out when overriding an existing class function, with an extension function of the same signature - will take effect?</p>
  
  <p>Here is my sample code:</p>
  
  <pre><code>fun String.toUpperCase(): String = "ext. function impl."
  
  fun main(args: Array&lt;String&gt;) {
  
      println("Hello".toUpperCase()) // ext. function impl.
  
      println(MyClass().toUpperCase()) // class impl.
  
  }
  
  class MyClass {
      fun toUpperCase() : String {
          return "class impl."
      }
  }
  
  fun MyClass.toUpperCase() : String {
      return "ext. function impl."
  }
  </code></pre>
  
  <p>So:</p>
  
  <ul>
  <li>What are the rules? when each will be called?</li>
  <li>How can I override this decision? is it possible?</li>
  </ul>