[ 
https://issues.apache.org/jira/browse/GROOVY-10980?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17715895#comment-17715895
 ] 

Eric Milles commented on GROOVY-10980:
--------------------------------------

Would a mixed-use case be considered a future enhancement? For example, 
[Complex|https://commons.apache.org/proper/commons-math/javadocs/api-3.6.1/org/apache/commons/math3/complex/Complex.html]
 and 
[Fraction|https://commons.apache.org/proper/commons-math/javadocs/api-3.6.1/org/apache/commons/math3/fraction/Fraction.html]
 provide add methods but {{double}}/{{Double}}, {{int}}/{{Integer}} and 
{{Number}} provide {{plus}}.
{code:groovy}
@Grab('org.apache.commons:commons-math:3.6.1')
import org.apache.commons.math3.complex.Complex
import org.apache.commons.math3.fraction.Fraction

@groovy.transform.OperatorRename(plus='add', types=[Complex,Fraction]) // could 
be "classes" or "appliesTo" or whatever
void test() {
  double x = 1.2d + 3.4d // still want "plus"
  double y = new Complex(5.6d) + 7.8d // want "add"

  // similarly for int/Integer and Fraction
}
{code}

> Provide an AST transform to rename operator methods
> ---------------------------------------------------
>
>                 Key: GROOVY-10980
>                 URL: https://issues.apache.org/jira/browse/GROOVY-10980
>             Project: Groovy
>          Issue Type: New Feature
>            Reporter: Paul King
>            Assignee: Paul King
>            Priority: Major
>             Fix For: 5.0.0-alpha-1
>
>




--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to