Kotlin / dukat

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

Imported entities name clash lead to override errors #315

Closed Schahen closed 4 years ago

Schahen commented 4 years ago

Consider following code: core.d.ts:

declare namespace Core {
    interface SomeEvent {}

    interface SomeDomain {
        add(evt: SomeEvent);
    }
}

events.d.ts:

declare module "myevents" {
    export interface SomeEvent extends Core.SomeEvent {}
}

index.d.ts:

/// <reference path="./core.d.ts" />
/// <reference path="./events.d.ts" />

declare module "mydomain" {
    import {SomeEvent} from "myevents";

    class MyDomain implements Core.SomeDomain {
        add(evt: SomeEvent); 
    }
}

After translation we end up with following MyDomain definition:

package mydomain

import myevents.SomeEvent
import Core.SomeDomain

external open class MyDomain : SomeDomain {
    open fun add(evt: SomeEvent)
    override fun add(evt: SomeEvent)
}

which won't compile because:

out/index.mydomain.module_node_3_minimal.kt:23:15: error: class 'MyDomain' is not abstract and does not implement abstract member public abstract fun add(evt: SomeEvent): Unit defined in Core.SomeDomain
external open class MyDomain : SomeDomain {
              ^
out/index.mydomain.module_node_3_minimal.kt:25:5: error: 'add' overrides nothing
    override fun add(evt: SomeEvent)

Here's what's happening here - SomeEvent from "events" and SomeEvent from core are actually clashing.