class A<K, L>
class B<K, L> {
fun <M> map(f: (L) -> M): B<K, M> = TODO()
}
class C<N>
fun <P, Q> buildB(builder: B<P, P>.() -> B<P, Q>): B<P, Q> = TODO()
fun <R, S, T> A<R, S>.connect(b: B<in S, T>): C<T> = TODO()
val foo: C<Int> = A<Int, String>().connect(buildB { map { it.length } })
// ^^^^^^^ - cannot infer T
// ^^^^^^ - cannot infer Q
Is it because the type checker has to go “too deep” into the AST? On the surface of it, it could figure out that T = Q (from equating types of parameter b in connect with return type of buildB: B<in S, T> = B<P, Q>), similarly, Q = M, and finally M = Int.
A more immediate question: what would be the minimal change that would introduce minimal amount of explicit types to make it compile?
Upgraded Kotlin plugin to 1.30, and everything is fine now. Strangely, in play.kotlinlang.org everything is fine as well. I must have done something stupid, maybe a typo or something…