Someone is confused here. Is it IntelliJ or the co...
# compiler
a
Someone is confused here. Is it IntelliJ or the compiler? Kotlin 1.6.21
I guess the compiler isn’t yet sure it’s going to be a list of
String
in the middle of the builder block, because I may add some other type later?
When I do
Copy code
val l = buildList {
    add("Hello")
    val s = get(0)
    s.
}
with the caret after the dot, IntelliJ suggests to insert
length
but then says unresolved reference. It does think the type of
s
is
String
e
a
Yeah
But I wonder why the compiler can’t infer the type. Is it because it processes the block statement-by-statement?
e
@BuilderInference
limitation. it only analyzes the type of the lambda after it has been processed
a
I see