blackdrag commented on code in PR #3227:
URL: https://github.com/apache/groovy/pull/3227#discussion_r4554048872


##########
src/main/java/org/codehaus/groovy/control/ResolveVisitor.java:
##########
@@ -1195,6 +1289,72 @@ protected Expression transformPropertyExpression(final 
PropertyExpression pe) {
         return isTopLevelProperty ? correctClassClassChain(xe) : xe;
     }
 
+    /**
+     * Whether a type found through a star import, a module import, or a 
default
+     * import is accessible from {@link #currentClass}.
+     * <p>
+     * Public types are visible. A package-private type stays visible in its 
own
+     * package, a protected member type stays visible to subclasses of its 
enclosing
+     * type, and a private member type stays visible inside the enclosing 
nest. A
+     * public member of an inaccessible enclosing type is not visible, so a 
star
+     * import cannot bind it.
+     * <p>
+     * Single-type imports are not filtered. An explicit {@code import 
p.Hidden}
+     * or a fully-qualified name still resolves, matching long-standing Groovy
+     * behaviour, and {@code Class.forName} is unaffected. Static field imports
+     * already apply an access check ({@link StaticImportVisitor}, since 
Groovy 5).
+     *
+     * @param type a resolved candidate
+     * @param knownOuter the type named by {@code import some.Type.*} when
+     *                   {@code type} is a binary member type that does not 
expose
+     *                   {@link ClassNode#getOuterClass()}
+     * @return {@code true} if the star import may bind {@code type}
+     */
+    private boolean isStarImportAccessible(final ClassNode type, final 
ClassNode knownOuter) {
+        ClassNode outer = type.getOuterClass();
+        if (outer == null) {
+            outer = knownOuter;

Review Comment:
   true, I overlooked line 839. But why does ConstructedNestedClass not return 
the outer class node it was constructed with on getOuterClass? If it would then 
that parameter would not be needed. Not sure about the side effects, but it 
would make sense to me.



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to