import groovy.transform.* // Script works without this. When you enable the line it causes a null Pointer Exception. In either way it compiles successfully. @CompileStatic class A { Integer a A(Integer a) { this.a = a } void doSomething() { println(a.toString()) } } def a = new A() a.doSomething()