GROOVY-12013: New optional type checking extension: CombinerChecker t…#2536
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new incubating type-checking extension to help catch incorrect combiners used with parallel reductions (Groovy’s sumParallel/injectParallel and JDK Stream#reduce), plus supporting annotations and documentation so users can declare/verify associativity and identity-element contracts.
Changes:
- Introduces
groovy.typecheckers.CombinerCheckerwith lenient/strict modes and Monoid/Semigroup carrier recognition. - Adds new
@Associativeand@Reducerannotations ingroovy.transformto declare combiner contracts (including optional identity viazero). - Adds spike-style tests and expands the typecheckers guide with a new section describing the checker and usage.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| subprojects/groovy-typecheckers/src/main/groovy/groovy/typecheckers/CombinerChecker.groovy | New type-checking extension that analyzes combiners for parallel reductions and stream reductions. |
| subprojects/groovy-typecheckers/src/test/groovy/groovy/typecheckers/CombinerCheckerTest.groovy | New tests covering lenient/strict behavior, carrier recognition, and stream reduce handling. |
| subprojects/groovy-typecheckers/src/spec/doc/typecheckers.adoc | Documentation entry + full section describing CombinerChecker behavior and configuration. |
| src/main/java/groovy/transform/Associative.java | New annotation to declare associativity contract for combiners. |
| src/main/java/groovy/transform/Reducer.java | New annotation to declare associativity + identity contract (optional zero). |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2536 +/- ##
==================================================
+ Coverage 68.1641% 68.1668% +0.0028%
- Complexity 32862 32901 +39
==================================================
Files 1499 1500 +1
Lines 125396 125520 +124
Branches 22666 22717 +51
==================================================
+ Hits 85475 85563 +88
- Misses 32408 32412 +4
- Partials 7513 7545 +32
🚀 New features to boost your workflow:
|
75fd0a9 to
e38a705
Compare
|
…o verify associative combiners in injectParallel/sumParallel/Stream.reduce
✅ All tests passed ✅🏷️ Commit: fcc8913 Learn more about TestLens at testlens.app. |



…o verify associative combiners in injectParallel/sumParallel/Stream.reduce
https://issues.apache.org/jira/browse/GROOVY-12013