# Package groovy.typecheckers

## Package groovy.typecheckers Description

Custom type checking extensions for compile-time validation, activated via `@TypeChecked(extensions = '...')` or `@CompileStatic(extensions = '...')`.

Stable checkers:

- groovy.typecheckers.RegexChecker – validates regex patterns and group counts at compile time
- FormatStringChecker – validates `printf` / `String.format` specifiers against argument types, paired with the @FormatMethod marker annotation for user-defined format methods

Incubating in 6.0.0 (semantics may evolve in a subsequent 6.x release):

- NullChecker – null-safety analysis using `@Nullable` / `@NonNull` / `@MonotonicNonNull` annotations, with an optional strict flow-sensitive mode
- ModifiesChecker – verifies method bodies comply with their @Modifies frame conditions
- groovy.typecheckers.PurityChecker – enforces that `@Pure` methods have no side effects, with configurable `allows` categories
- CombinerChecker – verifies that the combiner passed to a parallel reduction (`sumParallel`, `injectParallel`, `Stream.reduce`) carries the associativity contract those methods silently require
- MonadicChecker and MonadicShapeChecker – type-checking support for the `DO` macro and hand-written monadic chains over the standard carriers (`Optional`, `Stream`, `Awaitable`) and `@Monadic`-annotated types

- Class Summary
  Class | Description
  --- | ---
  CombinerChecker | A compile-time checker that verifies the combiner passed to an order-independent parallel reduction (`sumParallel`, `injectParallel`) carries the associativity contract those methods silently require — mirroring the design of `PurityChecker`.
  FormatStringChecker | Checks at compile-time for incorrect format strings in format methods such as `printf` and `String.format`.
  ModifiesChecker | A compile-time checker that verifies method bodies comply with their `@Modifies` frame condition declarations.
  MonadicChecker | Teaches `@CompileStatic`/`@TypeChecked` about the `DO` macro's desugared output: calls to `org.apache.groovy.runtime.Comprehensions.bind` and `.map`, declared `(Object, Closure):Object`.
  MonadicShapeChecker | Compile-time lint for native monadic chains over the standard carrier allow-list (MonadicCarrierRegistry).
  NullChecker | A compile-time type checker that detects potential null dereferences and null-safety violations in code annotated with `@Nullable`, `@NonNull`, and `@MonotonicNonNull` annotations.
  PurityChecker | A compile-time checker that verifies `@Pure` methods have no side effects.
  RegexChecker | Checks at compile-time for cases of invalid regex usage where the actual regex string can be identified (e.g. inline or defined by a local variable with an initial value or a field with an initial value).
  SqlInjectionChecker | Checks at compile-time for a common SQL injection mistake when using `groovy.sql.Sql`: surrounding an interpolated GString expression with SQL quotes, for example:
           sql.rows("select * from Book where title = '${title}'")   // '${...}'

- Annotation Type Summary
  Annotation Type | Description
  --- | ---
  FormatMethod | If this annotation is attached to a Formatter.format-like method, then when type-checking calls to the method, it will be a candidate method checked by FormatStringChecker.