blob: eeb445bc50e32877c6dff59b3600119cdb69f302 [file] [log] [blame]
package gls.annotations.closures
class AnnotationClosureWithNonLocalVariable extends GroovyTestCase {
void testVanillaVariable() {
assertScript """
import java.lang.annotation.*
@Retention(RetentionPolicy.RUNTIME)
@interface Foo {
Class value()
}
class X {
@Foo({ value })
def doit(value) {}
}
def clazz = X.class.getDeclaredMethod("doit",[Object] as Class[]).getAnnotation(Foo.class).value()
def closure = clazz.newInstance(this,this)
closure.delegate = [value:1]
assert closure() == 1
"""
}
}