Just curious: How do extension functions work in Kotlin? This is not about the syntax but about what is going on behind the scenes. What are the mechanics to add methods to arbitrary classes that can even be final (e.g. String)?
One more thing that is about syntax: how does Kotlin know which classes declare extension functions for other classes? After all, I could be loading a class that contains extension functions for String.class through a URLClassLoader. Is there a resolution order for finding extension functions and to disambiguate if there are two classes trying to add the same extension function?