dukat
dukat copied to clipboard
Generic params in lambdas are passed as is and causing compilation failure
This code
interface SomeOtherInterface {
ping: <T>(arg: T) => T;
}
is translated to:
external interface SomeOtherInterface {
var ping: (arg: T) -> T
}
Which won't compiled because we can not have standalone generic params in members. Actually, I am aware of this problem in general and we convert generated interfaces accordingly, for instance:
interface SomeOtherInterface {
cached: {
<T extends (...args: any[]) => any>(func: T) => any): T;
};
}
is converted to:
external interface `T$0`<T> {
@nativeInvoke
operator fun <T : (args: Array<Any>) -> Any> invoke(func: T, resolver: (args: Array<Any>) -> Any = definedExternally): T
}
external interface SomeInterface {
var cached: `T$0`<T>
}
It's just that we need to generalise this practice
more complete example
interface SomeOtherInterface {
ping: <T>(arg: T) => T;
pong<D>(arg: D): D;
cached: {
<T extends (...args: any[]) => any>(func: T) => any): T;
};
}
A good package for tracking success is fp-ts
which has tons of these issues.
I'm running into this issue running dukat against @types/google-protobuf
. The following two functions from the Message
class produce kotlin code which does not compile:
serializeBinaryExtensions(
proto: Message,
writer: BinaryWriter,
extensions: { [key: number]: ExtensionFieldBinaryInfo<Message> },
getExtensionFn: <T>(fieldInfo: ExtensionFieldInfo<T>) => T): void
readBinaryExtension(
proto: Message,
reader: BinaryReader,
extensions: {[key: number]: ExtensionFieldBinaryInfo<Message>},
setExtensionFn: <T>(fieldInfo: ExtensionFieldInfo<T>,
val: T) => void): void
If someone could point me in the right direction, I would be happy to try to fix this issue.