Possible typo in the documentation?

Sorry if I’m posting this in the wrong category. Please let me know if there’s a better channel to report this.

https://kotlinlang.org/docs/reference/lambdas.html#lambda-expression-syntax

The full syntactic form of lambda expressions is as follows:

val sum: (Int, Int) -> Int = { x: Int, y: Int -> x + y }


If we leave all the optional annotations out, what’s left looks like this:

val sum = { x, y -> x + y }

x and y must still have explicit types specified, right?

There’s another one that I found here
https://kotlinlang.org/docs/reference/this-expressions.html#qualified

Qualified this

To access this from an outer scope (a class, or extension function, or labeled function literal with receiver) we write this@label where @label is a label on the scope this is meant to be from:

class A { // implicit label @A
    inner class B { // implicit label @B
        fun Int.foo() { // implicit label @foo
            val a = this@A // A's this
            val b = this@B // B's this

            val c = this // foo()'s receiver, an Int
            val c1 = this@foo // foo()'s receiver, an Int

            val funLit = lambda@ fun String.() {
                val d = this // funLit's receiver
            }


            val funLit2 = { s: String ->
                // foo()'s receiver, since enclosing lambda expression
                // doesn't have any receiver
                val d1 = this
            }
        }
    }
}

This part

            val funLit = lambda@ fun String.() {
                val d = this // funLit's receiver
            }

has to be changed to

            val funLit = lambda@ fun String.() {
                val d = this@lambda // funLit's receiver
            }

x and y must still have explicit types specified, right?

I think no, this example just demonstrates the minimal possible form of a lambda. It doesn’t necessarily have to be compilable out of context.

has to be changed to

Unqualified this refers to funLit’s receiver here, so it’s correct.

Thanks, you’re right about the lambda example. Will fix this.
By the way, you can propose minor documentation fixes via the Edit Page button on the doc pages.