Kotlin / dukat

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

Extracted type aliases name clash #331

Closed Schahen closed 4 years ago

Schahen commented 4 years ago

Consider following code:

declare interface ICompiler {
}

declare namespace ICompiler {
    type Handler = () => void;
}

declare class Compiler implements ICompiler {
    ping(): Compiler.Handler;
}

declare namespace Compiler {
    type Handler = ICompiler.Handler;
}

Since we are merging namespaces and interfaces, we have to extract type aliases, and while we do so, we end up with following code:

typealias Handler = () -> Unit

typealias Handler = ICompiler.Handler

external interface ICompiler

external open class Compiler : ICompiler {
    open fun ping(): Compiler.Handler
}

The compilation of such code will cause lot of error: unresolved reference: Handler errors because of the name clash. Current proposal is to rename one of aliases if such clash occurs.