Github user jwagenleitner commented on a diff in the pull request:

    https://github.com/apache/groovy/pull/397#discussion_r76369713
  
    --- Diff: src/main/org/codehaus/groovy/control/ResolveVisitor.java ---
    @@ -852,6 +858,21 @@ protected Expression 
transformPropertyExpression(PropertyExpression pe) {
             return ret;
         }
     
    +    private boolean isVisibleNestedClass(ClassNode type, ClassNode ceType) 
{
    +        if (!type.isRedirectNode()) return false;
    +        ClassNode redirect = type.redirect();
    +        // public or private
    +        if (Modifier.isPublic(redirect.getModifiers()) || 
Modifier.isProtected(redirect.getModifiers())) return true;
    +        // package local
    +        PackageNode classPackage = ceType.getPackage();
    +        PackageNode nestedPackage = redirect.getPackage();
    +        if ((redirect.getModifiers() & (Modifier.PROTECTED | 
Modifier.PUBLIC | Modifier.PRIVATE)) == 0 &&
    +                ((classPackage == null && nestedPackage == null) ||
    +                        classPackage != null && nestedPackage != null && 
classPackage.equals(nestedPackage)))
    +            return true;
    +        return false;
    --- End diff --
    
    Comment says package local but it could be private at this point.  If you 
added an early exit `if (Modifier.isPrivate(redirect.getModifiers()) return 
false;` above the comment this would be package-private and the modifier check 
could be eliminated.
    
    If that's the case then the return could be simplified:
    
    ```
    return (classPackage == null && nestedPackage == null) || 
             (classPackage != null && classPackage.equals(nestedPackage))
    ```
    
    I notice that `PackageNode` doesn't implement `equals` so it will end up 
being an `==` check.  I'm not that familiar with how the AST is built and if 
the same `PackageNode` is used for a given name so just wanted to bring that up.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to