Kotlin / dukat

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

Enum class in namespace is not generated in presence of class with same name as namespace #439

Closed wfhartford closed 2 years ago

wfhartford commented 3 years ago

I'm trying to generate Kotlin wrapper code for typescript definitions generated by protocol buffers. Dukat consistently generated Kotlin that does not compile when a protocol buffer message has a oneof field. After eliminating a fair amount of unrelated code, the typescript definition code which causes the error is something like the following:

export class FooResponse {
  getResultCase(): FooResponse.ResultCase;
}

export namespace FooResponse {
  export enum ResultCase {
    RESULT_NOT_SET = 0,
    SUCCESS = 1,
    FAILURE = 2,
  }
}

When Dukat processes this file, it does not generate the ResultCase enum at all, but tries to import it:

// [annotation and standard imports redacted]
import FooResponse.ResultCase

external open class FooResponse {
    open fun getResultCase(): ResultCase
}

If the FooResponse class is not present, but the enum and namespace are, the enum will be generated.

wfhartford commented 3 years ago

Input .d.ts and output .kt file attached in a ZIP: 439.zip

wfhartford commented 3 years ago

If someone could give some advice on how to fix this issue, I'd be happy to spend some time on it. Thanks.

JSMonk commented 2 years ago

Fixed in https://github.com/Kotlin/dukat/pull/449