Lets say I have a class:
Foo {
always()
onlyScopeB()
}
And I have different methods, which take different closures: scopeA
, scopeB
foo = new Foo()
scopeA{
foo.always() // this should COMPILE
foo.onlyScopeB() // this should NOT COMPILE
}
scopeB{
foo.always() // this should COMPILE
foo.onlyScopeB() // this should COMPILE
}
Is there anyway to achieve this at the compilation stage? I am writing a DSL and I have scopes that correspond to stages in a process and sometimes fields are null
in one scope, and then other times they are not-null
and I am trying to provide the best semantic experience to find errors easily.