I'm trying to crate a type-safe groovy-style builder in Kotlin like it's described here. The problem is visibility of lambda receivers in nested lambdas. Here is a simple example.
html {
head(id = "head1")
body() {
head(id = "head2")
}
}
Receiver of the nested lambda is Body that doesn't have the 'head' method. Nevertheless this code compiles and prints into this:
<html>
<head id="head1"></head>
<head id="head2"></head>
<body></body>
</html>
It is expected but is there any way to get compilation error on the inner head?