Kotlin / dukat

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

Generic type translated incorrectly if looks like class name (TitleCase) #389

Closed liorgonnen closed 4 years ago

liorgonnen commented 4 years ago

This is a snippet from the three.js ObjectLoader.d.ts file:

export class ObjectLoader extends Loader {
    constructor( manager?: LoadingManager );

    load(
        url: string,
        onLoad?: <ObjectType extends Object3D>( object: ObjectType ) => void,
        onProgress?: ( event: ProgressEvent ) => void,
        onError?: ( event: Error | ErrorEvent ) => void
    ): void;
    parse<T extends Object3D>( json: any, onLoad?: ( object: Object3D ) => void ): T;

        // ...
    parseObject<T extends Object3D>(
        data: any,
        geometries: any[],
        materials: Material[]
    ): T;

}

When using Dukat, parse and parseObject are translated correctly to:

open fun <T : Object3D> parse(json: Any, onLoad: (obj: Object3D) -> Unit = definedExternally): T

and

open fun <T : Object3D> parseObject(data: Any, geometries: Array<Any>, materials: Array<Material>): T

But the load function is translated incorrectly to:

// Note that the generic definition for ObjectType is dropped:
open fun load(url: String, onLoad: (obj: ObjectType) -> Unit = definedExternally, onProgress: (event: ProgressEvent) -> Unit = definedExternally, onError: (event: dynamic /* Error | ErrorEvent */) -> Unit = definedExternally)

And it's missing the generic definition in front of the function name

trilis commented 4 years ago

Looks like #276

liorgonnen commented 4 years ago

Seems like a duplicate of #276 as mentioned by @trilis. Thanks!