Hello developers

I am developing a DSL and ran into this issue. Groovy auto infers that b is
really a derived clazz and allows me to call the derived clazz method. How
do I prevent this behavior from happening? Are there some settings in the
DeclarationExpression or VariableExpression AST models that will allow me
to prevent this and cause a compile error? (I am writing a compiler
customizer and so have access to do this)

void myMethod() {
>     BaseClazz b = new DerivedClazz()
>     b.callMethodDefinedOnlyInDerivedClazz("")
> }
>
>
Alternately, this seems to work correctly. But I'd rather not do it this
way if possible

void myMethod() {
>     BaseClazz b = (BaseClazz) new DerivedClazz()
>     b.callMethodDefinedOnlyInDerivedClazz("")
> }
>
> regards
Saravanan

Reply via email to