dimsuz
06/28/2021, 11:11 AMinline class InlinePayload(val id: String)
fun <T> test(t: T): T {
return t
}
val (p1, p2) = listOf(test(3))
.zip(
listOf(test(InlinePayload("a"))), // (1)
::Pair)
.first()
println(p2.id) // (2) EXCEPTION!
It seems that (1)
creates a List<String>
rather than List<InlinePayload>
and then (2)
crashes with
class java.lang.String cannot be cast to class ru.example.app.InlinePayload (java.lang.String is in module java.base of loader 'bootstrap'; ru.example.app.InlinePayload is in unnamed module of loader 'app')
dimsuz
06/28/2021, 11:14 AM::Pair
to
{ p1, p2 -> p1 to InlinePayload(p2.id) }
i.e if I "rewrap" then no crash occursDominaezzz
06/28/2021, 12:23 PMdimsuz
06/28/2021, 12:24 PM