Interesting, Java’s new structured concurrency fun...
# language-evolution
c
Interesting, Java’s new structured concurrency functions can’t be called using SAM conversion:
Copy code
StructuredTaskScope.open<Unit>().use {
    it.fork { foo2() }
}
because
fork
has two overloads,
Callable
and
Runnable
, which both have the signature
() -> Unit
in Kotlin (but have different signatures in Java because
void
is special) The simplest code I’ve managed to write is
Copy code
StructuredTaskScope.open<Unit>().use {
    it.fork(Callable { foo2() })
}
I wonder if there is simpler?
m
c
It’s rare to see overload resolution ambiguities in Kotlin that are not ambiguous in Java 😅 I’m so used to seeing the opposite
w
Tbh, since the API is not necessarily intended to be consumed directly by users. It’s more important to be on top of the designs of the people that build libraries and frameworks atop to make sure they’re ergonomic in Kotlin :)