I would like to prevent inheriting the top scope when using a function with receiver. The DSL marker is made for that but I find its behaviour to be pretty inconsistent.
Consider the 3 calls in the method run() : ideally all of them should lead to a compilation error because the DSL marker is present on each extension function parameter so nested calls of textFilter() should not be possible.
However, in the first case, the compiler ignores it, in the second it creates a warning and only in the third it leads to a compilation error.
Can someone please explain me this discrepancy ? Are there any workarounds to design a bulletproof DSL builder which prevent using extension functions out of their scope ?
As a side note, I noticed that if I put directly the annotation on the classes (TextContract, Container), then all three calls give me correctly an error. However in my real code, this is not possible because my classes are third party, so I would really like a solution with the annotation on the parameter.
Thanks is advance for any help