Hey Groovy people. Groovy currently supports operators like a+=b by decomposing them into a=a+b and + is implemented with a plus() method. Kotlin does something similar.
Kotlin also supports overloading "augmented assignments": https://kotlinlang.org/docs/operator-overloading.html#augmented-assignments which appears to just be another way of saying "assignment arithmetic operators." In Kotlin, a type can implement plusAssign and plus and the appropriate one will be selected depending on the scenario. My proposal is to add support in Groovy for these methods too. Groovy would start calling plusAssign instead of decomposing into an assignment and call to plus. There are details about fallbacks and differences between static and dynamic Groovy, but I'm happy to provide those if this seems like a reasonable idea. I would also be willing to implement this. My questions: Is this reasonable and what's the best way to discuss this further? Is it possible for this to be added to Groovy 4? The reason Groovy 4 is important to us is that Gradle 9 currently uses Groovy 4. We want to make API changes in Gradle 10 and the current behavior of += with FileCollections is causing some headaches. Getting support for overloading += directly in Gradle 9 could make the API changes in Gradle 10 less painful. Thanks! -- Sterling Greene Senior Lead Software Engineer Gradle Technologies gradle.com [image: image.png] -- * CONFIDENTIALITY NOTICE*: The contents of this email message, and any attachments, are intended solely for the addressee(s) and may contain confidential, proprietary and/or privileged information legally protected from disclosure. If you are not the intended recipient of this communication, or if you received this communication by mistake, please notify the sender immediately and delete this message and any attachments. If you are not the intended recipient, you are hereby notified that any use, retransmission, dissemination, copying or storage of this message or its attachments is strictly prohibited.
