Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non-cosmetic failures using @TupleConstructor on nested class #1216

Closed
chrylis opened this issue Jan 6, 2021 · 3 comments
Closed

Non-cosmetic failures using @TupleConstructor on nested class #1216

chrylis opened this issue Jan 6, 2021 · 3 comments
Assignees
Labels
Milestone

Comments

@chrylis
Copy link

chrylis commented Jan 6, 2021

Groovy-Eclipse sometimes drops spurious errors in the editor saying that a constructor added by @TupleConstructor can't be found, but these are generally cosmetic and don't result in actual compilation errors (i.e., no markers, code runs).

However, I've discovered that as of 3.0.7 having a static nested class (a record for a command type) annotated with @TupleConstructor causes actual errors using the Groovy-Eclipse compiler; the previous false alarm does generate a marker and a failing class file. A full clean and build, which usually handles mismatches because everything's available, doesn't help. mvn compile with groovyc works fine.

@eric-milles
Copy link
Member

eric-milles commented Jan 6, 2021

I would need an example project to take this further. In general, the transforms that add members to a class that are not already represented by an interface of Object (TupleConstructor vs ToString) cause problems. Example, class A has reference to class B. When compiling class A, the reference to B is resolved by processing class B as far as conversion. B is not fully processed because it may contain a direct or indirect reference to class A. This is discussed further in #704 and others.

@chrylis
Copy link
Author

chrylis commented Jan 7, 2021

Replicable. In order to reproduce:

  • nested class; inner or static does not matter
  • the client class must be @CompileStatic (the error is actually produced by the STC)
class Outer {
    @TupleConstructor(defaults = false)
    static class Nested {
        String value
    }
}

@CompileStatic
class Client {
    void foo() {
        new Nested('123')
    }
}

(Note that in the case of a top-level class the editor still shows the error, but the class does compile correctly anyway.)

@eric-milles
Copy link
Member

ready to test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants