-
Notifications
You must be signed in to change notification settings - Fork 193
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
GROOVY-10124: "refers to the missing type" error in Greclipse (not Groovy) #1300
Comments
I believe this is related to GROOVY-10124. Groovy and Java have different scope rules for the header of a class (annotations, generics, extends, implements). Adding a qualifier to the inner class type argument will fix resolution for JDT. class Response extends WithResultOperationResponse<Response.Result> {
// ^^^^^^^^^
static class Result ...
} |
If GROOVY-10124 was fixed, you would get an error in the groovy source as well. This could be done in greclipse ahead of groovy proper. I am unsure of doing that as pure groovy can still work as before. |
Having an error in the Groovy source is fine for me, at least you know what you should fix. I understand your concern of doing that in Greclipse before it's done in Groovy, but if the current behaviour prevents correct compilation under Eclipse, I think that having an error in the IDE even if it would be legitimate with plain groovyc is better than having an incomprehensible build error in the IDE anywhere else in the code... |
I will put out 4.3.0 release tomorrow. Then I will take a look at fixing the scope issue so you get a helpful error for 4.4.0. |
package p
class Outer extends X<Inner> {
static class Inner {}
} I have a bit of code worked up for #256 / GROOVY-8063 that represents the example above as the following in the Java model: package p;
import java.lang.*;
import java.util.*;
import java.io.*;
import java.net.*;
import groovy.lang.*;
import groovy.util.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import p.Outer.*;
public class Outer extends X<Inner> {
public static class Inner {
...
}
...
} The extra on-demand import at the end is enough help JDT find the inner class reference. This should deliver a more seamless experience in the IDE. |
This solution will only help top-level types. If you make this kind of reference, it will still fail: class Outer {
@Tag(Deeper.VALUE)
class Inner {
static class Deeper {
public final VALUE = ...
}
}
} |
Consider the attached project.
If you run
./gradlew jar
it will compile fine.However, if you open it in Greclipse and open the class
test.test.TestGreclipseError
, you'll see an error:Of course, the mentioned type is not missing.
This is quite annoying because Eclipse seems not to perform a clean build for this. I suspect the problem lies in
test.api.io.BaseResponse<T>
, which has a fieldresult
of the generic typeT
.If the fix is hard, a suggestion for a workaround would be much appreciated.
TestGroovyGradle.zip
Tested with Greclipse 4.3.0.v202109281919-e2009.
The text was updated successfully, but these errors were encountered: