Skip to content

Compilation error in Greclipse (not with groovyc/Gradle) #1360

@mauromol

Description

@mauromol

Using Greclipse 4.6.0.v202205032224-e2112, with Groovy 2.5 compiler (2.5.16 on build path).

Consider these Java classes/interfaces:

package testgen;
public interface MyInterface {
}

package testgen;
public class MyClass<T> {
}

package testgen;
import java.util.List;
public class MyClassE<T extends MyInterface> extends MyClass<T> {
    MyClassE(){}
    MyClassE(List<T> list) {
    }
}

And these Groovy classes:

package testgen
class MyBean implements MyInterface {
}

and:

package testgen
import groovy.transform.CompileStatic

@CompileStatic
class GClass {
   
    MyClassE<MyBean> foo
    
    void bar() {
	foo = new MyClassE<>(new ArrayList<>())
    }
}

The assignment is marked with an error in Greclipse:

Groovy:[Static type checking] - Incompatible generic argument types. Cannot assign testgen.MyClassE<testgen.
 MyInterface> to: testgen.MyClassE<testgen.MyBean>

This error is not given when compiling with Gradle/groovyc.
Also, if I replace that assignment with:

foo = new MyClassE<>()

no error is given by Greclipse as well. So it seems like the combination with the list is fooling Greclipse.

Workaround:

foo = new MyClassE<MyBean>(new ArrayList<>())

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions