groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Anton Sarov <>
Subject TypeChecked with apache commons Pair cannot find matching method
Date Mon, 22 Feb 2016 11:02:45 GMT
I have a DSL and some AST transformations. Now I would like to include some 3rd party classes
in my DSL. For example some apache commons lang classes like Pair, etc.
In my language I offer the user the "bar()" method (which I have defined elsewhere). However
the "bar()" method is just for user's convenience. Actually I am calling the "bar2()" method
under the hood - this is why I have the AST transformation.

So writing:
def foo = bar()
def foo = bar2() as Pair

Now consider this AFTER transformation statement:
def foo = bar2() as Pairfoo.getKey()foo.getValue()
Having the @TypeChecked annotation I get this error: Cannot find matching method org.apache.commons.lang3.tuple.Pair#getKey().
Please check if the declared type is right and if the method exists.

But if I write something like:
def foo = Pair.of(3,4)foo.getKey()foo.getValue()
Then everything is fine. Is there something that I am missing. What is even more weird: I
have my Type Checker extension and I see that "handleMissingMethod" is called for "foo.getKey()"
so at this point I try to resolve the statement by myself but calling "...getDeclaredMethods(..)"
returns an empty list.
Best regardsAnton

View raw message