@Incubating
class MonadicChecker
extends TypeCheckingDSL
Teaches @CompileStatic/@TypeChecked about the DO macro's
desugared output: calls to org.apache.groovy.runtime.Comprehensions.bind
and .map, declared (Object, Closure):Object.
Three jobs:
flatMap/map, or @Monadic); otherwise a
precise compile error naming the type and the missing shape.@Monadic, not structural): bind's closure must yield the
same carrier (catches a bare body or a cross-carrier body inside
DO, which the erased dispatcher signature otherwise lets through);
map's closure must not yield the same carrier (the
M<M<T>> foot-gun for hand-written Comprehensions.map)..get()/nesting type-check) instead
of the erased Object the dispatcher signature would yield.CLOSURE_ARGUMENTS on the
closure node, which StaticTypeCheckingVisitor.getTypeFromClosureArguments
consults by parameter name — independent of the Closure<?> parameter
not being a SAM type.
Activate with @CompileStatic(extensions='groovy.typecheckers.MonadicChecker'). | Constructor and description |
|---|
MonadicChecker() |
Copyright © 2003-2026 The Apache Software Foundation. All rights reserved.