I am trying to create a safe groovy line builder style in Kotlin, as described here . The problem is the visibility of lambdas in nested lambdas. Here is a simple example.
html { head(id = "head1") body() { head(id = "head2") } }
The receiver of a nested lambda is a Body that does not have a head method. However, this code is compiled and printed as follows:
<html> <head id="head1"></head> <head id="head2"></head> <body></body> </html>
It is expected, but is there a way to get a compilation error on the inner head?
source share