You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by GitBox <gi...@apache.org> on 2020/07/18 19:05:41 UTC

[GitHub] [groovy] eric-milles opened a new pull request #1318: GROOVY-5103: allow plain star imports to pick up static inner types

eric-milles opened a new pull request #1318:
URL: https://github.com/apache/groovy/pull/1318


   https://issues.apache.org/jira/browse/GROOVY-5103
   
   - Java allows "import foo.Bar.*" to resolve "Baz" to "foo.Bar$Baz"
   
   - Note: This is also a compatibility/transparency issue for Eclipse Groovy Development Tools, which has supported star imports that resolve inner types for years.
   
   Checking star imports for type reference is limited to "real" star imports (those present in the source text) to prevent trying to resolve "java.lang", "java.util", etc. for every single `ModuleNode`.  Type resolution also enables display of Javadoc information for the imported type:
   ![image](https://user-images.githubusercontent.com/18193802/87860033-96c61100-c8ff-11ea-9222-993dc1189acd.png)


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [groovy] paulk-asert commented on pull request #1318: GROOVY-5103: allow plain star imports to pick up static inner types

Posted by GitBox <gi...@apache.org>.
paulk-asert commented on pull request #1318:
URL: https://github.com/apache/groovy/pull/1318#issuecomment-660549908


   Merged, thanks.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [groovy] asfgit closed pull request #1318: GROOVY-5103: allow plain star imports to pick up static inner types

Posted by GitBox <gi...@apache.org>.
asfgit closed pull request #1318:
URL: https://github.com/apache/groovy/pull/1318


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [groovy] paulk-asert commented on pull request #1318: GROOVY-5103: allow plain star imports to pick up static inner types

Posted by GitBox <gi...@apache.org>.
paulk-asert commented on pull request #1318:
URL: https://github.com/apache/groovy/pull/1318#issuecomment-660549463


   This seems okay. It doesn't seem to break the existing import of static classes using "import static", which while possibly unexpected from a Java point-of-view, we have supported for a long time. I'll note that your patch doesn't extend to another "exotic" case we currently support.
   ```
   import java.util.Map as SomeMap
   import static SomeMap.Entry as SomeEntry
   
   assert SomeEntry instanceof Class
   ```
   works but not without the static. It is also somewhat unusual but accounts for aliases to some degree and we have supported it for along time too. We can cover that off separately.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [groovy] paulk-asert commented on pull request #1318: GROOVY-5103: allow plain star imports to pick up static inner types

Posted by GitBox <gi...@apache.org>.
paulk-asert commented on pull request #1318:
URL: https://github.com/apache/groovy/pull/1318#issuecomment-660559360


   Not planning to shut it down at this stage. I have had numerous folks (albeit quite a few years ago now) who've come up to me at conferences and expressed their like for that feature and how it made it easier for DSLs and various porting scenarios.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [groovy] eric-milles commented on pull request #1318: GROOVY-5103: allow plain star imports to pick up static inner types

Posted by GitBox <gi...@apache.org>.
eric-milles commented on pull request #1318:
URL: https://github.com/apache/groovy/pull/1318#issuecomment-660556422


   > ... your patch doesn't extend to another "exotic" case we currently support.
   > 
   > ```
   > import java.util.Map as SomeMap
   > import static SomeMap.Entry as SomeEntry
   > 
   > assert SomeEntry instanceof Class
   > ```
   > 
   > works but not without the static. It is also somewhat unusual but accounts for aliases to some degree and we have supported it for along time too. We can cover that off separately.
   
   If you wanted to shut down this "exotic" behavior, you could change this bit:
   ```
       public void visitClass(final ClassNode node) {
           ...
               for (ImportNode importNode : module.getStaticImports().values()) {
                   ClassNode type = importNode.getType();
                   if (resolve(type, true, true, true)) continue; // set flags to "false, false, true" to not use other imports to help resolve this import
                   addError("unable to resolve class " + type.getName(), type);
               }
   ```
   
   Just an option to consider.  I don't think anyone coming into the language is expecting one import to influence another.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org