You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@groovy.apache.org by John Wagenleitner <jo...@gmail.com> on 2018/05/15 18:32:46 UTC

Fwd: groovy git commit: GROOVY-5912: Static compilation: Groovy doesn't fail compilation when accessing package scope methods, but fails at runtime

Just a question, I thought that @TypeChecked is designed to work similar to
dynamic mode as far as method dispatch and access (i.e., private/protected
ok). If filtering methods by visibility is done in the
`StaticTypeCheckingVisitor` wouldn't change that behavior. Is that
something expected for 2.5?

P.S. Also seems the following line should include a "same package" check as
well

if (methodNode.isProtected() &&
> !enclosingClassNode.isDerivedFrom(declaringClass)) {
>     continue;
> }


---------- Forwarded message ---------
From: <su...@apache.org>
Date: Tue, May 15, 2018 at 8:44 AM
Subject: groovy git commit: GROOVY-5912: Static compilation: Groovy doesn't
fail compilation when accessing package scope methods, but fails at runtime
To: <co...@groovy.apache.org>


Repository: groovy
Updated Branches:
  refs/heads/GROOVY_2_5_X d1970bcf6 -> 7804d4ea9


GROOVY-5912: Static compilation: Groovy doesn't fail compilation when
accessing package scope methods, but fails at runtime

(cherry picked from commit b1cc8a6)

[.....]

+++
b/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
@@ -4415,6 +4415,9 @@ public class StaticTypeCheckingVisitor extends
ClassCodeVisitorSupport {
             if (methodNode.isProtected() &&
!enclosingClassNode.isDerivedFrom(declaringClass)) {
                 continue;
             }
+            if (methodNode.isPackageScope() &&
!getPackageName(enclosingClassNode).equals(getPackageName(declaringClass)))
{
+                continue;
+            }

             result.add(methodNode);
         }
@@ -4422,6 +4425,12 @@ public class StaticTypeCheckingVisitor extends
ClassCodeVisitorSupport {
         return result;
     }

[.....]