groovy-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jochen Theodorou <blackd...@gmx.org>
Subject Re: suggestion: ImplicitSafeNavigation annotation
Date Tue, 14 Aug 2018 16:34:09 GMT

I have to confess I do like the NPE. It is usually one of the most easy 
to fix exceptions. But well, not everyone likes to program with that I 
understand ;)

More comments inline

Am 14.08.2018 um 15:07 schrieb ocs@ocs:
[...]
> For the moment, the best solution — far as I have been able to ascertain 
> — consists of [*]
> 
> (a) at launch, setting own DelegatingMetaClass subclass for a 
> Null.metaclass; it essentially would return null from invokeMethod, but 
> still needs to process special cases (like e.g., null.is 
> <http://null.is>(foo)) explicitly;

so for general Groovy... how are we supposed to recognized in a 
transform if "is" has been replaced?

> (b) since the above for some godforsaken reason does not work for 
> property access at all, still implement an ASTT with 
> a ClassCodeExpressionTransformer to set expression.safe=true for 
> get/setProperty, guarding explicitly against the known problematic cases 
> (e.g., super.getProperty).

are you saying x?.foo will NPE if x is null? Or that x?.getFoo() will 
NPE in that case? Not sure how to read your comment.

> For all I know, this probably would not work properly 
> with @CompileStatic (which I do not use at all myself, but others do 
> frequently).

the result type could be a problem... Worth to check.

> Trust me, been there, done that. I am pretty darn sure it would be 
> /infinitely/ easier and, what's important, more reliable in the core 
> with an explicit compiler support.

How about making a small github project to dump the current state there?

bye Jochen

Mime
View raw message