On 08.04.24 13:56, Paul King wrote:
[...]
What I wanted to show is the same examples but using the '==' and '!='
operators, since that would be the typical Groovy style for this
scenario. Unfortunately, using the type checking extension DSL doesn't
currently work for binary operators. The swap from '==' to the
'equals' method call occurs well after type checking is finished. The
same would apply to operators eventually falling back to 'compareTo'.

the replacements may be even on ScriptBytecodeAdapter.

You can still make it work by not using the DSL and writing your own
type checking extension, but that's significantly more work.

Our options seem to be:
(1) not trying to make this work
(2) modify operators to method call expressions earlier (might remove
some optimization steps)
(3) tweak StaticTypeCheckingVisitor#visitBinaryExpression to support
before/after method call hooks for known cases like equals/compareTo
with a pretend method call
(4) alter the TypeCheckingExtension interface with before/after binary
expression calls.

[...]

Does anyone have strong opinions on this before I start having a play
and seeing what might work? In particular, a preference for option 3
or 4?

Doing that only for special cases does not sound right to me. I would be
for option 4... is there anything speaking against that?

bye Jochen

Reply via email to