You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2020/02/19 15:34:00 UTC

[jira] [Comment Edited] (GROOVY-9407) ImportCustomizer skips importing in certain scenarios

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

Eric Milles edited comment on GROOVY-9407 at 2/19/20 3:33 PM:
--------------------------------------------------------------

Please note that ImportCustomizer adds imports to the ModuleNode, not the ClassNode, so they are not scope-limited to the ClassNode.  It looks like you are trying to provide imports for only the matching class in [CompilerAutoConfiguration|https://github.com/dreis2211/groovy3-import-bug/blob/master/src/main/java/org/dreis/CompilerAutoConfiguration.java].

GROOVY-8399 was implemented because a source unit with 10 classes would end up with 10 copies of each import customization.  This resulted in a lot of extra lookups during semantic analysis.


was (Author: emilles):
Please note that ImportCustomizer adds imports to the ModuleNode, not the ClassNode, so they are note scope-limited to the ClassNode like you are providing in [CompilerAutoConfiguration|https://github.com/dreis2211/groovy3-import-bug/blob/master/src/main/java/org/dreis/CompilerAutoConfiguration.java].

GROOVY-8399 was implemented because a source unit with 10 classes would end up with 10 copies of each import customization.  This resulted in a lot of extra lookups during semantic analysis.

> ImportCustomizer skips importing in certain scenarios
> -----------------------------------------------------
>
>                 Key: GROOVY-9407
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9407
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 3.0.1
>            Reporter: Christoph Dreis
>            Priority: Major
>
> Hi,
> when upgrading Spring-Boot to Groovy 3.x (see [https://github.com/spring-projects/spring-boot/issues/20119]) I was noticing build failures around the importing behaviour.
> I've managed to extract a minimum example where this breaks:
> [https://github.com/dreis2211/groovy3-import-bug]
> It seems that *ImportCustomizer* is skipping imports when multiple classes (or more specifically ClassNodes) are in the same file and the imports are configured per class/ClassNode. Please see the above example for more information.
> This behaviour seems to have been introduced with GROOVY-8399 for performance reasons.
> When switching the example to 2.5.9, it works again.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)