[ https://issues.apache.org/jira/browse/GROOVY-8509?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16404971#comment-16404971 ]
Eric Milles edited comment on GROOVY-8509 at 3/19/18 3:27 PM: -------------------------------------------------------------- I think this can be remedied by adding a same package check: {code:java} } else if (target.isProtected()) { ClassNode node = receiver==null?ClassHelper.OBJECT_TYPE:controller.getTypeChooser().resolveType(receiver, controller.getClassNode()); boolean isThisOrSuper = false; if (receiver instanceof VariableExpression) { isThisOrSuper = ((VariableExpression) receiver).isThisExpression() || ((VariableExpression) receiver).isSuperExpression(); } // GRECLIPSE edit -- GROOVY-8509 //if (!implicitThis && !isThisOrSuper if (!implicitThis && !isThisOrSuper && !node.getPackageName().equals(classNode.getPackageName()) // GRECLIPSE end && StaticTypeCheckingSupport.implementsInterfaceOrIsSubclassOf(node,target.getDeclaringClass())) { {code} Probably needs a null check since getPackageName() does return null explicitly. was (Author: emilles): I think this can be remedied by adding a same package check: {code:java} } else if (target.isProtected()) { ClassNode node = receiver==null?ClassHelper.OBJECT_TYPE:controller.getTypeChooser().resolveType(receiver, controller.getClassNode()); boolean isThisOrSuper = false; if (receiver instanceof VariableExpression) { isThisOrSuper = ((VariableExpression) receiver).isThisExpression() || ((VariableExpression) receiver).isSuperExpression(); } // GRECLIPSE edit -- GROOVY-8509 //if (!implicitThis && !isThisOrSuper if (!implicitThis && !isThisOrSuper && !node.getPackageName().equals(classNode.getPackageName()) // GRECLIPSE end && StaticTypeCheckingSupport.implementsInterfaceOrIsSubclassOf(node,target.getDeclaringClass())) { {code} > SC: error for call to protected method from same package > -------------------------------------------------------- > > Key: GROOVY-8509 > URL: https://issues.apache.org/jira/browse/GROOVY-8509 > Project: Groovy > Issue Type: Bug > Affects Versions: 2.5.0-beta-2, 2.6.0-alpha-3 > Reporter: Eric Milles > Priority: Major > > Groovy 2.5+ is producing compilation errors for @CompileStatic test class > calling a protected method of class under test (in same package). This > should be allowed as protected is "package-private" plus subtypes. -- This message was sent by Atlassian JIRA (v7.6.3#76005)