-
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
Compilation error "type Proxy is ambiguous" #1354
Comments
Due to groovy/groovy-eclipse#1354, without an explicit import for java.net.Proxy, there will be a compilation error: "The type Proxy is ambiguous"
Due to groovy/groovy-eclipse#1354, without an explicit import for java.net.Proxy, there will be a compilation error: "The type Proxy is ambiguous"
I have a fix for the editor to retain the import(s) necessary for name disambiguation. With that out of the way, the ambiguous reference error from the compiler is in keeping with ecj's handling of the situation. You can use a fully-qualified name if you don't want to keep fighting with the editor's import handling. |
Thanks for the Eclipse IDE fix. I do not use Eclipse, though. Follow-up questions:
|
Yes, I would think IDEA would require similar handling. Not sure what they do for Java in the same situation. Although implicit imports add a bit of nuance. The situation can occur in Java as well. The classic example is import java.awt.*;
import java.util.*;
...
List // ambiguous reference Eclipse wants to ensure that it makes no difference if the imports are reordered. Groovy adds extra default star imports beyond The groovy compiler resolves type references starting with explicit imports followed by star imports. This is handled by I think it is safer to stick with the ambiguous reference error versus suppressing it. There have been instances where the Groovy default imports were reordered for performance (to reduce lookups) and this kind of change could destabilize an application that relies on order of star imports. |
For reference: I just created IDEA-291430 |
JDK 11, Groovy 2.5.16, GrEclipse 3.7.1, GrEclipse Batch 2.6.16-02.
An MCVE is here. Just clone it and run
mvn test
. You will see:The error goes away if I import either of these here
IntelliJ IDEA shows both of them greyed out and removes the imports, because both seem to be imported by default in Groovy already. Other classes of that name which are visible from JRE or dependencies are
net.sf.cglib.proxy.Proxy
,org.graalvm.compiler.nodes.spi.Proxy
,java.lang.reflect.Proxy
, but those are not automatically imported, so they are fine.I am not sure if this is a Groovy compiler or core problem, but it is kind of suboptimal that two identically named classes are imported by default. The error goes away if I import one of the two on top, but always marked as redundant and removed when reorganising imports, which is dangerous, but understandable, because the IDE correctly identifies them both as available.
The text was updated successfully, but these errors were encountered: