groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfaustin <pds.oga...@gmail.com>
Subject How to add a method which accepts a generic type parameter?
Date Sat, 26 Sep 2015 21:56:38 GMT
Hi, everyone

I need through an AST Transformation add a method which accepts a generic
type parameter to script. 
For example:
I have a script

> @Test
> package test
>
> test([key: value, key: value])

I want to add the method

> private test(Map map) {
>     map.eah {...}
> }

But when I was trying to implement it I got a error: 

"A transform used a generics containing ClassNode java.util.Map <K extends
java.lang.Object -> java.lang.Object, V extends java.lang.Object ->
java.lang.Object> for the method private java.lang.Object 
test(java.util.Map map)  { ... } directly. You are not supposed to do this.
Please create a new ClassNode referring to the old ClassNode and use the new
ClassNode instead of the old one. Otherwise the compiler will create wrong
descriptors and a potential NullPointerException in TypeResolver in the
OpenJDK. If this is not your own doing, please report this bug to the writer
of the transform."

Is there is an article or example how add a method which accepts a generic
type parameter?



--
View this message in context: http://groovy.329449.n5.nabble.com/How-to-add-a-method-which-accepts-a-generic-type-parameter-tp5727838.html
Sent from the Groovy Users mailing list archive at Nabble.com.

Mime
View raw message