groovy-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Wagenleitner <john.wagenleit...@gmail.com>
Subject Fwd: groovy git commit: GROOVY-5912: Static compilation: Groovy doesn't fail compilation when accessing package scope methods, but fails at runtime
Date Tue, 15 May 2018 18:32:46 GMT
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: <sunlan@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: <commits@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;
     }

[.....]

Mime
View raw message