Kotlin: Cannot import-on-demand from object

Although you cannot import package.KotlinObject.* from a Kotlin object directly, you can import package.*. To avoid unnecessary or ambiguous imports, simply create a new package, declare the classes, variables or extensions you wish to import inside a raw .kt file and then import-on-demand from the parent package.


Sparkot is your Kotlin class, if I understand it's right. Objects may inherit things from supertypes, e.g. equals(), hashCode() will be imported every time you* import from an object, and the decision was made that this would be too confusing.

* - imports work only with Java object.

Tags:

Java

Kotlin