I'm trying to group a set of extension methods in a class object. I've can done this way:
import kotlin.template.*
class A {
fun instanceName()=“A instance”
}
class B {
class object {
fun A.extendedName():String="According to B is "+instanceName()
fun bName()=A().extendedName()
}
}
fun main(args : Array<String>) {
println(A().instanceName())
println(B.bName())
//println(A().extendedName()) The compiler give an error here. extension is not directly visible
}
But it’s a bit ugly, because I have to provide a non-extension method (bName in the example) to give external visibility to extendedName().
Is this a compiler bug, or am I missing something?