Olof Asbrink created GROOVY-10319:
-------------------------------------

             Summary: Groovy3 CompileStatic bug: Method clone is protected in 
java.lang.Object
                 Key: GROOVY-10319
                 URL: https://issues.apache.org/jira/browse/GROOVY-10319
             Project: Groovy
          Issue Type: Bug
          Components: Static compilation
    Affects Versions: 3.0.8
         Environment: JDK11 (11.0.12)
            Reporter: Olof Asbrink


The following code compiles on groovy 2 but does not compile on groovy 3
{code:java}
package a.b.c

import groovy.transform.CompileStatic

@CompileStatic
class ABC implements DEF {
    public double[] _array

    ABC() { }

    DEF clone() {
        ABC abc = (ABC) super.clone()
        abc._array = _array.clone() as double[]
        return abc
    }
}

public interface DEF extends Cloneable {
    public DEF clone() throws CloneNotSupportedException;
}
 {code}
It gives the following error message:
{code:java}
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
ABC.groovy: 15: Method clone is protected in java.lang.Object @ line 15, column 
22.
           abc._array = _array.clone() as double[]
                        ^

1 error
{code}
However if I don't put the class in a package (i.e. remove {{package a.b.c}}) 
it compiles fine.

(this might relate to this issue: 
https://issues.apache.org/jira/browse/GROOVY-9874)




--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to