Hi Anton! How, in your AST transformation, do you create the class node for `Pair`?
2016-02-22 12:02 GMT+01:00 Anton Sarov <[email protected]>: > Hello, > > 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() > > Becomes: > > def foo = bar2() as Pair > > Now consider this AFTER transformation statement: > > def foo = bar2() as Pair > foo.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 regards > Anton >
