Kotlin / dukat

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

Name clash not resolved when conflicting entity is nested in a class #303

Open Kiryushin-Andrey opened 4 years ago

Kiryushin-Andrey commented 4 years ago

Consider the following type declarations:

declare namespace A {
    class Foo {}
    class Bar {}
    namespace Bar {
        class Foo extends A.Foo {}
    }
}

We have a name clash here between the two Foo classes - the one declared directly in namespace A and the other nested in a Bar class.

Dukat v0.5.0 outputs the following Kotlin code (I omit imports and file annotations here):

package A

external open class Foo

external open class Bar {
    open class Foo : Foo
}

This code does not compile because of a looped inheritance hierarchy. I expect the Bar class to look like this instead:

external open class Bar {
    open class Foo : A.Foo
}

I found this issue when converting TypeScript declarations for Google Maps JS API (https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/googlemaps/reference). There is a MouseEvent interface defined in google.maps namespace there and another one MouseEvent interface defined in google.maps.events that inherits from the first one. The resulting generated Kotlin code contains the same inheritance hierarchy loop for this interface.

Schahen commented 4 years ago

looks related to https://github.com/Kotlin/dukat/issues/296