[ 
https://issues.apache.org/jira/browse/GROOVY-10706?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17572147#comment-17572147
 ] 

Paul King commented on GROOVY-10706:
------------------------------------

I assumed we only checked ambiguities when both were explicit but we don't do 
that either:
{code:java}
import java.util.List;
import java.awt.List;

@groovy.transform.CompileStatic
static void main(args) {
  println List
}
{code}
This is currently valid and last found wins rather than first found wins with 
star imports!


> Consider tightening of star import rules for type checked code
> --------------------------------------------------------------
>
>                 Key: GROOVY-10706
>                 URL: https://issues.apache.org/jira/browse/GROOVY-10706
>             Project: Groovy
>          Issue Type: Improvement
>          Components: Static Type Checker
>            Reporter: Paul King
>            Priority: Major
>
> When faced we multiple star imports, dynamic Groovy has a rule whereby first 
> seen match wins. With type checking, we might want to consider tightening up 
> the rules and giving an error if duplicates are found, e.g.:
> {code}
> import java.awt.*;
> import java.util.*;
> @groovy.transform.CompileStatic
> static void main(args) {
>   println List
> }
> {code}
> The Java equivalent would complain with something like:
> {noformat}
> error: reference to List is ambiguous
>         System.out.println(List.class);
>                            ^
>   both interface java.util.List in java.util and class java.awt.List in 
> java.awt match
> 1 error
> {noformat}
> This might have performance impacts though, so we'd need to investigate that 
> as part of the analysis.



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

Reply via email to