George
02/08/2023, 11:04 AMtypealias RSocketData<T> = ByteArray
@OptIn(ExperimentalSerializationApi::class)
inline fun <reified T> ProtoBuf.decodeFromRSocketData(value: RSocketData<T>): T {
return this.decodeFromByteArray(value)
}
@OptIn(ExperimentalSerializationApi::class)
fun testT() {
val protoBuf = ProtoBuf
val data: RSocketData<String> //= TODO()
val request = protoBuf.decodeFromRSocketData(data) // Not enough information to infer type variable T
}
Does anyone knows why the compiler cannot infer type of T through data? Thanks in advance for any answers !George
02/08/2023, 11:09 AMclass TypedRSocketData<T>(val data: ByteArray)
It seems to work. I guess after the compilation typealias turns to ByteArray
which does not have any info about T?George
02/08/2023, 11:15 AM