Kotlin / dukat

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

Problems with having same-name declarations on top level and inside another class #386

Open trilis opened 3 years ago

trilis commented 3 years ago

spark-md5:

// copy of ArrayBuffer because of a conflict with the class SparkMD5.ArrayBuffer
interface ArrayBufferCopy extends ArrayBuffer {}

declare namespace SparkMD5 {
    class ArrayBuffer {
                append(str: ArrayBufferCopy): ArrayBuffer;
    }
}

generated code:

import SparkMD5.ArrayBuffer

external interface ArrayBufferCopy : ArrayBuffer

@JsModule("definitely-typed")
external open class SparkMD5 {
    open class ArrayBuffer {
        open fun append(str: ArrayBufferCopy): ArrayBuffer
    }
}

And because of this import, ArrayBufferCopy is inherited from SparkMD5.ArrayBuffer, not from stdlib org.khronos.webgl.ArrayBuffer, as it should be.

Another related, but a bit different problem is reproduced on oracle__oraclejet/ojrouter. Because of some merging, we end up with structure like this:

external open class Router {
    open var currentState: () -> RouterState?
    interface RouterState
}
external open class RouterState

If we examine FQN of currentState, we will find that this type should be reference to top-level <ROOT>.RouterState, but with no imports or other manipulations compiler will treat it as Router.RouterState by default.