You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Marat Kamalov (Jira)" <ji...@apache.org> on 2023/03/29 13:09:00 UTC

[jira] [Created] (GROOVY-10995) Wrong class compilation validation

Marat Kamalov created GROOVY-10995:
--------------------------------------

             Summary: Wrong class compilation validation
                 Key: GROOVY-10995
                 URL: https://issues.apache.org/jira/browse/GROOVY-10995
             Project: Groovy
          Issue Type: Bug
          Components: Compiler
    Affects Versions: 4.0.10
            Reporter: Marat Kamalov


We use Groovy 3. And I tried to migrate the existing application to use Groovy 4. 

I have a compilation issue in the code and the same behavior in IntelliJ IDEA, because it uses Groovy 4 syntax by default.

What I have:

 
{code:java}
// A simple interface with generic parameter
interface MyInterface<T> {
} {code}
{code:java}
// A simple annotation that expects an MyInterface implemenations
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
@interface MyAnnotation {
    Class<? extends MyInterface<?>> value()
} {code}
{code:java}
//A class that implements MyInterface and ignores type raw type using warnings
public class MyClass implements MyInterface { 
}
{code}
 
{code:java}
// A method that uses MyAnnotation with MyClass parameter
@MyAnnotation(value = com.example.MyClass)
static void main(String[] args) { 
}{code}
This code compiles in Groovy 3 and compiles in Java but fails to compile in Groovy 4.0.10

The code starts to compile in Groovy 4 If I change MyClass implementation to:
{code:java}
public class MyClass implements MyInterface<Object> {
} {code}



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