The code below :
package experimental import experimental.AnObject.f interface AnInterface { fun String.a() = "[AnInterface] $this" } object AnObject { fun AnInterface.f(str: String) = "[AnObject]" + str.a() } class AnInterfaceImpl : AnInterface fun main() { println( AnInterfaceImpl().f("hi") ) }
prints [AnObject][AnInterface] hi
[AnObject][AnInterface] hi
My question is, how does the call to AnInterfaceImpl().f ends up resolved to the extension function in AnObject
AnInterfaceImpl().f
AnObject
1.4m articles
1.4m replys
5 comments
57.0k users