Xiaotian Ma created GROOVY-11549:
------------------------------------

             Summary: False positive "Can't have an abstract method in a 
non-abstract class." when implement Java interfaces
                 Key: GROOVY-11549
                 URL: https://issues.apache.org/jira/browse/GROOVY-11549
             Project: Groovy
          Issue Type: Bug
          Components: Compiler
    Affects Versions: 4.0.24, 5.0.0-alpha-11
            Reporter: Xiaotian Ma


h1. Source code

The following code should be compiled, but actually not.
{code:java}
// Java Files
// FILE: I0.java
public interface I0<T> {
    public T func();
}
// FILE: I1.java
public interface I1 extends I0<String> {
    @Override
    default String func() {
        return "I1";
    }
}
{code}
{code:groovy}
// Groovy File
// FILE: B.groovy
public class B implements I1, I0<String> {
}
{code}
h1. Error
{code:none}
B.groovy
Groovyc: Can't have an abstract method in a non-abstract class. The class 'B' 
must be declared abstract or the method 'java.lang.Object func()' must be 
implemented.
{code}
h1. Expected output
Compiler should pass this code.
h1. Other
Method "java.lang.Object func()" has already overridden in Java interface "I1" 
with a type argument "String". If I remove the type parameter "T" in "I0", like 
this:

{code:java}
// Java Files
// FILE: I0.java
public interface I0 {
    public String func();
}
// FILE: I1.java
public interface I1 extends I0 {
    @Override
    default String func() {
        return "I1";
    }
}
{code}
the error disappear. As far as I know, Java compiler will generate a bridge 
method "java.lang.Object func()" in "I1" in bytecode. So maybe the groovy 
compiler misread the bridge method in "I1"? 



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

Reply via email to