Kotlin / dukat

Converter of <any kind of declarations> to Kotlin external declarations
552 stars 44 forks source link

No explicit import generated for types with the same name as stdlib types #379

Closed trilis closed 4 years ago

trilis commented 4 years ago
export interface Image {
  //...
}
export namespace templateBuilders {
  abstract class TemplateBuilder<T> {
        setBackgroundImage(image: Image): T;
  }
}

We would generate two files:

external interface Image

and

package templateBuilders
//...
import org.w3c.dom.*
//...
external open class TemplateBuilder<T> {
    open fun setBackgroundImage(image: Image): T
}

This compiles, but with wrong Image:

We probably should generate something like this:

package templateBuilders
//...
import org.w3c.dom.*
import Image
//...
external open class TemplateBuilder<T> {
    open fun setBackgroundImage(image: Image): T
}

The only reason why we don't generate it this way now is FQN of this Image -- it would be resolved as <ROOT>.Image, and we can't determine by this FQN if it's custom-defined or stdlib-defined. We probably should improve our FQN resolve logic