It is more a case of the AST transforms running into a Groovy feature.
Groovy doesn't let you compile this class:

class Foo {
    private foo() {}
    public foo(String s) {}
}

It might seem strange but it has been that way for a long time.

Can you change "makeSense" to protected?

Paul.

On Tue, Jan 28, 2025 at 5:53 PM OCsite <o...@ocs.cz> wrote:
>
> Hi there,
>
> do I make some mistake not understanding properly those two ASTTs, or is this 
> a Groovy bug?
>
> Thanks!
> OC
>
> ===
>
> 975 ocs /tmp> <nv.groovy
>
> import groovy.transform.*
>
> import groovy.transform.options.*
>
> class Test {
>
>   @NamedVariant @VisibilityOptions(Visibility.PUBLIC) private makeSense(int 
> dollars, int cents) {
>
>     "d:$dollars c:$cents"
>
>   }
>
> }
>
> def t=new Test()
>
> println t.makeSense(dollars: 2, cents: 50)
>
> 976 ocs /tmp> /usr/local/groovy-4.0.24/bin/groovy nv
>
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup 
> failed:
>
> /private/tmp/nv.groovy: 4: Mixing private and public/protected methods of the 
> same name causes multimethods to be disabled and is forbidden to avoid 
> surprising behaviour. Renaming the private methods will solve the problem.
>
>  @ line 4, column 3.
>
>      @NamedVariant @VisibilityOptions(Visibility.PUBLIC) private 
> makeSense(int dollars, int cents) {
>
>      ^
>
>
> /private/tmp/nv.groovy: -1: Mixing private and public/protected methods of 
> the same name causes multimethods to be disabled and is forbidden to avoid 
> surprising behaviour. Renaming the private methods will solve the problem.
>
>  @ line -1, column -1.
>
> 2 errors
>
>
> 977 ocs /tmp>
>
> ===

Reply via email to