blackdrag commented on code in PR #3019:
URL: https://github.com/apache/groovy/pull/3019#discussion_r4386539542
##########
src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java:
##########
@@ -3300,6 +3300,11 @@ && findMethod(receiver, "<init>",
init(argumentTypes)).size() == 1) {
}
if (ctor != null) {
storeTargetMethod(call, ctor);
+ // GROOVY-12484: a public constructor of an inaccessible
type is still out of reach
+ if (!call.isSpecialCall() &&
!hasAccessToClass(typeCheckingContext.getEnclosingClassNode(), receiver)) {
+ addStaticTypeError("Cannot access constructor of
class: " + prettyPrintTypeName(receiver)
+ + " from class: " +
prettyPrintTypeName(typeCheckingContext.getEnclosingClassNode()), call);
Review Comment:
I doubt the approach a bit. Normally what I want is to select the
method/ctor from the available and accessible methods. The reason this does not
work here is if there is a DGM method provided as ctor. But that is afaik a
mechanism we do not support even in dynamic Groovy. I would either do the check
earlier or consider to change findMethod
--
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]