Kotlin - How i can access my new class extension function from another file

I believe that there is a misunderstanding here about extension functions. Extension functions are regular static functions that take in an instance of the receiver class as a parameter implicitly when you define the function and operate on it.

These static functions (aka extension functions) have some limitations.

They are not added to the class hierarchy so subclasses can not inherit them (if you define extension function for parent class you can't expect that method to be present in child class)

They don't have access to the private properties of the class that they are extending.

Also, they are resolved statically, for example (taken from here)

open class Shape

class Rectangle: Shape()

fun Shape.getName() = "Shape"

fun Rectangle.getName() = "Rectangle"

fun printClassName(s: Shape) {
  println(s.getName())
}     

printClassName(Rectangle())

This example prints "Shape", because the extension function being called depends only on the declared type of the parameter s, which is the Shape class.


The answer for my question, that satisfies me is just to extract the method to some "object" structure in other file and whenever we want to access that function we must import the path(package.object.method) to this.

But the problem is, that IDE is not propose me the path to my extension function - i must import it by myself.

I am using Android Studio 3 preview, hope this will be fixed.

UPDATE

It is better to define those function in just plain Kotlin file, so the functions will be not owned by any structure. Then it will be not a problem with importing those automatically by IDE from any place.