As of version 1.2.9 GContracts  - a Design by Contract library - supports Groovy's @CompileStatic and @TypedChecked annotations. With Groovy 2.0, @CompileStatic can be used to execute type checks during compile time, bypass the Groovy meta object protocol and force a Java-like byte-code generation.@TypeChecked can be used to apply type checks only.
The newest version of GContracts enriches certain elements of the abstract syntax tree with type information during compile time.
Static Typing and Contracts == <3
Before 2.0, applying @Invariant, @Requires and @Ensures on code written in a dynamic language has been half-baked. As class definitions could be changed during runtime, there was always the chance of a contract being implicitly violated although the contract did successfully evaluate beforehand.
With @TypeChecked and @CompileStatic we can ensure type safety and therefore strengthen the applicability of GContracts. Check out the following statically typed Stack example:
The above example shows a statically compiled Stack class, that is fully annotated with pre-/postconditions and a class invariant.
Cool stuff - how can I get it?
If you want to play with GContracts and Groovy 2.0 and its static typing features, download Groovy , fire up the groovyConsole, copy and paste the above example and you are ready to go with GContracts and Groovy.
Alternatively, you can use GContracts in your Gradle project by adding compile 'org.gcontracts:gcontracts-core:1.2.9' to your build.gradle.
For an introduction to static typing and compilation in Groovy 2.0 I would suggest watching this Gr8Conf presentation by Cédric Champeau .