Kotlin / dukat

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

Conflicting override while merging class and interface extending eponymous namespaces interface #330

Closed Schahen closed 4 years ago

Schahen commented 4 years ago

Following code:

// _api.d.ts
declare namespace API {
  interface Module {
    children: Module[];
  }
}

interface ApiModule extends API.Module {}

/// <reference path="./_api.d.ts" />

// index.d.ts
declare module "mymodule" {
  interface Module extends ApiModule {}
  class Module {
    children: API.Module[];
  }
}

Leads to creating (among other things) of following declaration:

external open class Module : ApiModule {
    override var children: Array<Module>
    override var children: Array<API.Module>
}

The introduction of first children is obviously a bug and, of course, this leads to a compilation errors:

a/aaa.mymodule.kt:23:18: error: conflicting declarations: public open var children: Array<mymodule.Module>, public open var children: Array<API.Module>
    override var children: Array<Module>
                 ^
a/aaa.mymodule.kt:23:28: error: type of 'children' doesn't match the type of the overridden var-property 'public abstract var children: Array<API.Module> defined in ApiModule'
    override var children: Array<Module>
                           ^
a/aaa.mymodule.kt:24:18: error: conflicting declarations: public open var children: Array<mymodule.Module>, public open var children: Array<API.Module>
    override var children: Array<API.Module>