title: Kotlin extension method as alias for long method name?
body: <p>I am working in Kotlin using a Kotlin-native library object containing a method whose <code>.nameIsMuchTooLongAndIsStillNotClear</code>.  In a manner similar to <code>typealias</code>, I want to create an alias to the method, so I can refer to it as something <code>.shortAndClear</code>.  To complicate matters slightly, these functions have several parameters, many of which have defaults that I'd prefer not to pre-process in a wrapper.  After further research, it still seems like an <a href="https://kotlinlang.org/docs/reference/extensions.html#extension-functions" rel="noreferrer">extension function</a> is the way to go.</p>
  
  <p>To use an <em>example function</em> that's easy to test, let's say I want to create an alias-type extension for <code>String.startsWith</code> that is called <code>String.beg</code>.  I can easily get the following solution to work:</p>
  
  <pre><code>inline fun String.beg(prefix: CharSequence, ignoreCase: Boolean = false) = startsWith(prefix, ignoreCase)   // works ok
  </code></pre>
  
  <p>However, this seems to require that I list all argument and their defaults, and do so for every overload.  (The real method signatures in question are considerably longer with many more defaults.)  In the spirit of "don't repeat yourself", is there a way I can use a <a href="https://kotlinlang.org/docs/reference/reflection.html#function-references" rel="noreferrer">function reference</a> to <code>String::startsWith</code> so that I don't have to enumerate all arguments? I've tried several forms, but none of them work:</p>
  
  <pre><code>// none of these work:
  fun String.beg = String::startsWith
  fun String.beg = this::startsWith
  val String.beg: (CharSequence, Boolean) -&gt; Boolean = String::startsWith
  </code></pre>